Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87151 Details for
Bug 215346
JVM service provider
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
implementation of jvm provider
215346.txt (text/plain), 34.99 KB, created by
Igor Alelekov
on 2008-01-17 08:33:28 EST
(
hide
)
Description:
implementation of jvm provider
Filename:
MIME Type:
Creator:
Igor Alelekov
Created:
2008-01-17 08:33:28 EST
Size:
34.99 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.agentcontroller >Index: src-native-new/src/transport/TPTPClientCompTL/TPTPClientCompTL.dsp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/src/transport/TPTPClientCompTL/TPTPClientCompTL.dsp,v >retrieving revision 1.10 >diff -u -r1.10 TPTPClientCompTL.dsp >--- src-native-new/src/transport/TPTPClientCompTL/TPTPClientCompTL.dsp 28 Mar 2006 19:33:34 -0000 1.10 >+++ src-native-new/src/transport/TPTPClientCompTL/TPTPClientCompTL.dsp 17 Jan 2008 13:30:31 -0000 >@@ -54,7 +54,7 @@ > # ADD BSC32 /nologo > LINK32=link.exe > # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 >-# ADD LINK32 rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib /nologo /dll /machine:I386 /out:"../../../bin/tptpCCTL.dll" /libpath:"../../../lib" >+# ADD LINK32 rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib tptpJava.lib /nologo /dll /machine:I386 /out:"../../../bin/tptpCCTL.dll" /libpath:"../../../lib" > > !ELSEIF "$(CFG)" == "TPTPClientCompTL - Win32 Debug" > >@@ -81,7 +81,7 @@ > # ADD BSC32 /nologo > LINK32=link.exe > # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept >-# ADD LINK32 tptpBaseTL.lib rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib /nologo /dll /debug /machine:I386 /out:"../../../bin/tptpCCTL.dll" /pdbtype:sept /libpath:"$(JAVA_HOME)/lib" /libpath:"../../../lib" >+# ADD LINK32 tptpBaseTL.lib rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib tptpJava.lib /nologo /dll /debug /machine:I386 /out:"../../../bin/tptpCCTL.dll" /pdbtype:sept /libpath:"$(JAVA_HOME)/lib" /libpath:"../../../lib" > > !ENDIF > >Index: src-native-new/src/transport/TPTPClientCompTL/java.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/src/transport/TPTPClientCompTL/java.h,v >retrieving revision 1.2 >diff -u -r1.2 java.h >--- src-native-new/src/transport/TPTPClientCompTL/java.h 13 Mar 2006 20:48:56 -0000 1.2 >+++ src-native-new/src/transport/TPTPClientCompTL/java.h 17 Jan 2008 13:30:31 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006 IBM Corporation and others. >+ * Copyright (c) 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -76,7 +76,7 @@ > > > /* Functions */ >-tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *dllPath, tptp_string *classpath); >+tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *classpath); > tptp_uint32 tptpSubmitJavaJob(tl_state_data_t* stateData, tptpJavaJobImplementation *jobImpl, BOOL asynchronous, TID *tid); > tptp_uint32 tptpDestroyJavaVirtualMachine(tl_state_data_t* stateData); > >Index: src-native-new/src/transport/TPTPClientCompTL/ClientCTL.c >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/src/transport/TPTPClientCompTL/ClientCTL.c,v >retrieving revision 1.44 >diff -u -r1.44 ClientCTL.c >--- src-native-new/src/transport/TPTPClientCompTL/ClientCTL.c 14 Jan 2008 11:16:46 -0000 1.44 >+++ src-native-new/src/transport/TPTPClientCompTL/ClientCTL.c 17 Jan 2008 13:30:31 -0000 >@@ -56,9 +56,6 @@ > BOOL jvmCreated; > TID _fileServerTID; > TID _secsvrtid; >- tptp_string *classpath; >- tptp_int32 classPathSize=8096; >- tptp_int32 result; > tptp_string *isDataMultiplexed; > tptp_string *processPolling; > tptp_string *securityEnabled; >@@ -122,14 +119,7 @@ > // In this case the config file does not have the ACProtocolPort entry. > cctlData->acProtocolPort = 10006; > } >- rc = getConfigurationString( pTransportData->configurationData, "Jvm", &cctlData->jvm ); >- if ( rc == -1 ) >- { >- cctlData->jvm = NULL; >- /* We don't really have a default JVM location.*/ >- /* Should this be a failure condition? */ >- TPTP_LOG_ERROR_MSG( stateData, "No JVM was specified in serviceconfig.xml. File transfer and SSL support will be disabled." ); >- } >+ > rc = getConfigurationString( pTransportData->configurationData, "SecurityEnabled", &securityEnabled ); > if ( rc == 0 ) > { >@@ -205,42 +195,15 @@ > /* Assume NO Security for now !!! */ > /******************************/ > /* Create JVM */ >- if (!cctlData->jvm) >+ rc = tptpCreateJavaVitualMachine(stateData, NULL); >+ if (rc == 0) { >+ jvmCreated = TRUE; >+ } >+ else > { > TPTP_LOG_WARNING_MSG( stateData, "Cannot create JVM and therefore cannot create file server" ); > jvmCreated = FALSE; > } >- else >- { >-/* ra_getEnvironmentVariable() has some bugs still, so continue to >- * use workaround in setconfig for now. >- */ >- /* Get the classpath from the system environment */ >- classpath = tptp_malloc(sizeof(tptp_string) * classPathSize); >- //We are using a goto statement... which I admit is ugly. >- //we should address this case as well as the general environment case which >- //uses the same technique. >-retry: >- result = ra_getEnvironmentVariable("CLASSPATH", classpath, classPathSize); >- if (result>classPathSize) { >- classPathSize=result+1; >- classpath = tptp_realloc(classpath, sizeof(tptp_string) * classPathSize); >- goto retry; >- >- } >- TPTP_LOG_DEBUG_MSG1(stateData, "CLASSPATH used for staring file server = %s", classpath); >- >- /* Create the JVM */ >- rc = tptpCreateJavaVitualMachine(stateData, cctlData->jvm, classpath); >- tptp_free(classpath); >- if (rc == 0) >- jvmCreated = TRUE; >- else >- { >- TPTP_LOG_WARNING_MSG( stateData, "Cannot create JVM and therefore cannot create file server" ); >- jvmCreated = FALSE; >- } >- } > > /* Start createFileServer */ > if (jvmCreated) >Index: src-native-new/src/transport/TPTPClientCompTL/java.c >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/src/transport/TPTPClientCompTL/java.c,v >retrieving revision 1.2 >diff -u -r1.2 java.c >--- src-native-new/src/transport/TPTPClientCompTL/java.c 24 Feb 2006 01:41:07 -0000 1.2 >+++ src-native-new/src/transport/TPTPClientCompTL/java.c 17 Jan 2008 13:30:31 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >-* Copyright (c) 2006 IBM Corporation and others. >+* Copyright (c) 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,6 +12,7 @@ > > #include "java.h" > #include "ClientCTL.h" >+#include "tptp/TPTPJava.h" > > #ifdef _WIN32 > #include <windows.h> >@@ -40,7 +41,6 @@ > /** > * FILE SCOPE VARIABLES > */ >-static JNIEnv *_mainThread; > static int _currentJavaJobId = 0; > > >@@ -53,125 +53,11 @@ > > void *JavaJob(void *args); > >- >-tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *dllPath, tptp_string *classpath) { >- jint result; /* the result of JVM creation */ >- JavaVMInitArgs vmArgs; /* the JVM arguments */ >- JavaVMOption options[NUM_JVM_OPTIONS]; /* the options inside the JVM argument structure */ /* Bug 62342 */ >- tptp_string *buffer; /* the pointer to the class path to be loaded with the JVM */ >- tptp_uint32 bufferSize, offset; /* the size and offset of the string buffer to be allocated for the class path */ >-#ifdef _WIN32 >- tptp_string *jvmArgBuffer; /* Bug 62342 */ >-#elif defined(__OS400__) >- tptp_string *versionBuffer; /* Bug 95493 the pointer to the version to be loaded with the JVM */ >-#endif >- >-#ifndef __OS400__ >- tptpCreateJavaVM vmCreationFunction; /* the entry point of JNI_CreateJavaVM() call */ >- DLL_REFERENCE dllRef; /* the pointer to the dynamic library */ >- >- if (!dllPath) return -1; >- >- /* Load the dynamic library. */ >- if (!(dllRef = LOAD_LIBRARY(dllPath))) { >- TPTP_LOG_WARNING_MSG1(stateData, "Couldn't load JVM library %s", dllPath); >- return -1; >- } >- else { >- TPTP_LOG_DEBUG_MSG1(stateData, "Loaded JVM library %s", dllPath); >- } >- >- /* Resolve the entry point. */ >- if (!(vmCreationFunction = (tptpCreateJavaVM) RESOLVE_ENTRY_POINT(dllRef, "JNI_CreateJavaVM"))) { >- TPTP_LOG_WARNING_MSG(stateData, "Couldn't resolve entrypoint for JNI_CreateJavaVM"); >- return -2; >- } >- else { >- TPTP_LOG_DEBUG_MSG(stateData, "Resolved entrypoint for JNI_CreateJavaVM"); >- } >-#endif >- offset = strlen("-Djava.class.path"); >- /* Construct the class path for this JVM. This path can be of an arbitrary length. */ >- bufferSize = strlen("-Djava.class.path=") + 1; >- if (classpath) >- { >- bufferSize+= strlen(classpath); >- } >- buffer = (tptp_string*)tptp_malloc(sizeof(tptp_string) * bufferSize); >- BZERO(buffer, bufferSize); >- strcpy(buffer, "-Djava.class.path="); >- if (classpath) >- { >- strcat(buffer, classpath); >- } >-/* memcpy(buffer, "-Djava.class.path=", offset); >- memcpy(buffer + offset + 1, classpath, strlen(classpath));*/ >- >- /* Bug 62342 begins */ >- vmArgs.nOptions = 0; >-#ifdef _WIN32 >- /* Add the -Xrs option to prevent JVM shutdown upon user logoff */ >- jvmArgBuffer = (char*)tptp_malloc(sizeof(char) * (strlen("-Xrs") + 1)); >- BZERO(jvmArgBuffer, strlen("-Xrs") + 1); >- memcpy(jvmArgBuffer, "-Xrs", strlen("-Xrs")); >- options[vmArgs.nOptions].optionString = jvmArgBuffer; >- vmArgs.nOptions++; >-#endif >- >- /* Set all options for the JVM. */ >- if(classpath != NULL) { >-#if defined(__OS400__) /* Bug 95493 */ >- versionBuffer = (char*)tptp_malloc(sizeof(char) * 19); >- BZERO(versionBuffer, 19); >- memcpy(versionBuffer, "-Djava.version=1.4", 18); >- options[vmArgs.nOptions].optionString = as400_etoa(versionBuffer); >- vmArgs.nOptions++; >-#endif >- >-#ifdef __OS400__ >- /* Set the class path using what is in the CLASSPATH variable. The encoding conversion must be done at run-time. */ >- options[vmArgs.nOptions].optionString = as400_etoa(buffer); >-#elif defined MVS >- __etoa(buffer); >- options[vmArgs.nOptions].optionString = buffer; >-#else >- options[vmArgs.nOptions].optionString = buffer; >-#endif >- vmArgs.nOptions++; >- } >- >- if(vmArgs.nOptions == 0) { >- vmArgs.options = NULL; >- } >- else { >- vmArgs.options = options; >- } >- >- /* Bug 62342 ends */ >- >- vmArgs.version = JNI_VERSION_1_2; >- vmArgs.ignoreUnrecognized = JNI_FALSE; >- >- /* Instantiate the JVM, and clean up. */ >-#ifdef __OS400__ >- result = JNI_CreateJavaVM(&_java_VM, (void**)&_mainThread, (void*)&vmArgs); >- tptp_free(options[0].optionString); >-#else >- result = (*vmCreationFunction)(&_java_VM, (void**)&_mainThread, (void*)&vmArgs); >-#endif >- >- tptp_free(buffer); >-#ifdef _WIN32 >- tptp_free(jvmArgBuffer); /* Bug 62342 */ >-#elif defined(__OS400__) >- tptp_free(versionBuffer); /* Bug 95493 */ >-#endif >- >- return result ? -1 : 0; >- >+tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *classpath) { >+ _java_VM = tptpCreateJVM(classpath); >+ return (_java_VM != NULL) ? 0 : -1; > } > >- > tptp_uint32 tptpSubmitJavaJob(tl_state_data_t* stateData, tptpJavaJobImplementation *jobImpl, BOOL asynchronous, TID *tid) { > tptpJavaJobWrapper* ptr; /* the pointer to the wrapper for the function pointer */ > >Index: src-native-new/src/shared/tptpConfig/tptpConfig.def >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/src/shared/tptpConfig/tptpConfig.def,v >retrieving revision 1.5 >diff -u -r1.5 tptpConfig.def >--- src-native-new/src/shared/tptpConfig/tptpConfig.def 17 Oct 2005 22:30:42 -0000 1.5 >+++ src-native-new/src/shared/tptpConfig/tptpConfig.def 17 Jan 2008 13:30:30 -0000 >@@ -19,3 +19,5 @@ > copyVariableNode > destroyVariableT > destroyVariableNode >+ getTPTPConfig >+ getEnvironmentVariable >Index: src-native-new/src/shared/tptpConfig/TPTPConfig.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/src/shared/tptpConfig/TPTPConfig.cpp,v >retrieving revision 1.62 >diff -u -r1.62 TPTPConfig.cpp >--- src-native-new/src/shared/tptpConfig/TPTPConfig.cpp 21 Nov 2007 15:24:33 -0000 1.62 >+++ src-native-new/src/shared/tptpConfig/TPTPConfig.cpp 17 Jan 2008 13:30:30 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 Intel Corporation. >+ * Copyright (c) 2005, 2008 Intel Corporation. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -36,7 +36,6 @@ > #include <xercesc/parsers/XercesDOMParser.hpp> > > >- > XERCES_CPP_NAMESPACE_USE > > #include "tptp/ParserErrorHandler.h" >@@ -74,6 +73,7 @@ > char *applicationAliasPtr = NULL; > static sysEnv_list_t *cacheEnv = NULL; > >+static AC_Config_t *_ac_config = NULL; > > void setEnvironmentVariable(char *name, char *value); > agent_metadata_t* tptp_findAgent(tptp_list_t* agentList, char *agentName); >@@ -164,17 +164,19 @@ > { > DOMAttr *attributeNode = (DOMAttr*) attributes->item(i); > char *cattrname = XMLString::transcode(attributeNode->getName()); >- char *cattrvalue = XMLString::transcode(attributeNode->getValue()); > >- if(strcmp(cattrname, attrName) == 0) >- { >- *attrValue = (char *)tptp_malloc(strlen(cattrvalue)+1); >+ if(strcmp(cattrname, attrName) == 0) { >+ char *cattrvalue = XMLString::transcode(attributeNode->getValue()); >+ >+ *attrValue = (char *) tptp_malloc(strlen(cattrvalue)+1); > strcpy(*attrValue, cattrvalue); >+ >+ XMLString::release(&cattrvalue); > } > >- XMLString::release(&cattrvalue); > XMLString::release(&cattrname); > } >+ > return 0; > } > >@@ -1743,6 +1745,11 @@ > TPTP_LOG_DEBUG_MSG1("Process Controller exe %s",ac_config->procCntlrAgent); > > } >+ else if(strcmp(tempnodename, ELEMENT_NAME_JVM) == 0) { >+ if (!getAttrs(iter->getCurrentNode(), "location", &ac_config->jvmLibPath)) { >+ TPTP_LOG_DEBUG_MSG1("JVM location is %s", ac_config->jvmLibPath); >+ } >+ } > else if(strcmp(tempnodename, ELEMENT_NAME_AGENT) == 0) > { > char *tmpAgentDirName=NULL; >@@ -1939,6 +1946,8 @@ > delete tptp_dom_err; > parser->release(); > >+ _ac_config = ac_config; >+ > return 0; > } //end try > >@@ -1975,6 +1984,11 @@ > } > } > >+ >+AC_Config_t* getTPTPConfig() { >+ return _ac_config; >+} >+ > /** > ********************************************************************* > * >Index: src-native-new/include/tptp/TPTPConfig.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/include/tptp/TPTPConfig.h,v >retrieving revision 1.11 >diff -u -r1.11 TPTPConfig.h >--- src-native-new/include/tptp/TPTPConfig.h 7 Feb 2007 19:08:35 -0000 1.11 >+++ src-native-new/include/tptp/TPTPConfig.h 17 Jan 2008 13:30:30 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 Intel Corporation. >+ * Copyright (c) 2005, 2008 Intel Corporation. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -99,6 +99,7 @@ > tptp_list_t agentList; /* agent_metadata_t */ > tptp_list_t msgPipelineList; /* message_pipeline_t */ > char *procCntlrAgent; >+ char *jvmLibPath; > struct ConnectionManager_tag* connectionManager; > } AC_Config_t; > >@@ -131,6 +132,7 @@ > void printList(tptp_list_t *inputList); > > int loadTPTPConfig(char *acConfigFile, AC_Config_t *ac_config, BOOL calledByAC); >+AC_Config_t* getTPTPConfig(); > int parseApplicationAliases(char *applicationString, tptp_list_t **pUserAppList, int *launchAliasesOnly); > int parseApplication(char *applicationString, App_Label_t **pLabel); > >@@ -252,5 +254,7 @@ > #define ELEMENT_NAME_AGENT_CFGFILE "ConfigFile" > //Agent Config - AgentName > #define ATTRB_AGENT_NAME "Name" >+// JVM configuration >+#define ELEMENT_NAME_JVM "Jvm" > > #endif /*TPTPCONFIG_H_*/ >Index: src-native-new/src/TPTPJava/TPTPJava.c >=================================================================== >RCS file: src-native-new/src/TPTPJava/TPTPJava.c >diff -N src-native-new/src/TPTPJava/TPTPJava.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/TPTPJava/TPTPJava.c 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,242 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Intel Corporation, IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * $Id: TPTPJava.c,v 1.0 2008/01/17 03:35:47 ialelekov Exp $ >+ *******************************************************************************/ >+ >+/* >+ * TPTP JVM provider >+ * >+ * TODO: error logging, thread synchronization >+ * >+ */ >+ >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+ >+#include "tptp/TPTPConfig.h" >+#include "tptp/TPTPJava.h" >+ >+#define DEFINE_CLASSPATH "-Djava.class.path=" >+ >+typedef jint (JNICALL *CreateJavaVM)(JavaVM**, void**, void*); >+ >+JavaVM* jvm = NULL; >+ >+ /* Get the classpath from the system environment */ >+char* getSystemClasspath() { >+ int classPathSize = 8096; >+ char* classpath; >+ int result; >+ >+ classpath = (char*) malloc(classPathSize); >+ while (1) { >+ result = getEnvironmentVariable("CLASSPATH", classpath, classPathSize); >+ if (result <= classPathSize) break; >+ >+ classPathSize = result + 1; >+ classpath = realloc(classpath, classPathSize); >+ } >+ >+ return classpath; >+} >+ >+int createJVM(const char* classpath) { >+ DLL_REFERENCE jvmLib; >+ CreateJavaVM vmCreate; >+ JavaVMInitArgs vmArgs; >+ JavaVMOption options[2]; >+ JNIEnv* jenv = NULL; >+ char* cpe=NULL; >+ char* cp=NULL; >+ int cplen; >+ jint result; >+ AC_Config_t* cfg; >+ >+ cfg = getTPTPConfig(); >+ if (cfg == NULL) return AC_CONFIG_NOT_FOUND; >+ if (cfg->jvmLibPath == NULL) return JVM_LIB_NOT_SET; >+ >+ // Load the dynamic library. >+ if(!(jvmLib = LOAD_LIBRARY(cfg->jvmLibPath))) return JVM_LOAD_ERROR; >+ >+ // Resolve the entry point. >+ if(!(vmCreate = (CreateJavaVM) RESOLVE_ENTRY_POINT(jvmLib, "JNI_CreateJavaVM"))) { >+ return JVM_RESOLVE_ERROR; >+ } >+ >+ vmArgs.nOptions = 0; >+ >+#ifdef _WIN32 >+ // Add the -Xrs option to prevent JVM shutdown upon user logoff >+ options[vmArgs.nOptions++].optionString = "-Xrs"; >+#endif >+ >+ cplen = 0; >+ if (classpath != NULL) >+ cplen = strlen(classpath); >+ >+ cpe = getSystemClasspath(); >+ if (cpe != NULL) cplen += strlen(cpe); >+ >+ if (cplen > 0) { >+ cp = (char*) malloc(cplen + strlen(DEFINE_CLASSPATH) + 2); // including PATH_SEPARATOR >+ strcpy(cp, DEFINE_CLASSPATH); >+ >+ if (classpath != NULL) strcat(cp, classpath); >+ >+ if (cpe != NULL) { >+ if (classpath != NULL) { >+ cplen = strlen(cp); >+ *(cp + cplen) = PATH_SEPARATOR; >+ *(cp + cplen + 1) = '\0'; >+ } >+ >+ strcat(cp, cpe); >+ } >+ >+ options[vmArgs.nOptions++].optionString = cp; >+ } >+ >+ vmArgs.options = options; >+ vmArgs.version = JNI_VERSION_1_2; >+ vmArgs.ignoreUnrecognized = JNI_FALSE; >+ >+ // Instantiate the JVM, and clean up. >+ result = (*vmCreate)(&jvm, (void**)&jenv, (void*)&vmArgs); >+ >+ if(cp != NULL) free(cp); >+ if(cpe != NULL) free(cpe); >+ >+ return (result == 0) ? 0 : JVM_CREATION_ERROR; >+} >+ >+static jstring nativeToJavaString(JNIEnv *env, const char *s) { >+ jclass clsString; >+ jmethodID mthInit; >+ jbyteArray ba = NULL; >+ jstring jstr; >+ int slen; >+ >+ clsString = (*env)->FindClass(env, "java/lang/String"); >+ if (clsString == NULL) return NULL; >+ >+ mthInit = (*env)->GetMethodID(env, clsString, "<init>", "([B)V"); >+ if (mthInit == NULL) return NULL; >+ >+ slen = strlen(s); >+ ba = (*env)->NewByteArray(env, slen); >+ if (ba == NULL) return NULL; >+ >+ (*env)->SetByteArrayRegion(env, ba, 0, slen, (jbyte *)s); >+ jstr = (*env)->NewObject(env, clsString, mthInit, ba); >+ (*env)->DeleteLocalRef(env, ba); >+ >+ return jstr; >+} >+ >+static char *JavaToNativeString(JNIEnv *env, jstring jstr) { >+ jclass clsString; >+ jmethodID mthGetBytes; >+ jbyteArray ba = NULL; >+ jthrowable ex; >+ jint slen; >+ char *s = NULL; >+ >+ clsString = (*env)->FindClass(env, "java/lang/String"); >+ if (clsString == NULL) return NULL; >+ >+ mthGetBytes = (*env)->GetMethodID(env, clsString, "getBytes", "()[B"); >+ if (mthGetBytes == NULL) return NULL; >+ >+ ba = (*env)->CallObjectMethod(env, jstr, mthGetBytes); >+ ex = (*env)->ExceptionOccurred(env); >+ if (ex != NULL) { >+ (*env)->DeleteLocalRef(env, ex); >+ return NULL; >+ } >+ >+ slen = (*env)->GetArrayLength(env, ba); >+ s = (char *) malloc(slen + 1); >+ >+ (*env)->GetByteArrayRegion(env, ba, 0, slen, (jbyte *)s); >+ *(s+slen) = 0; >+ >+ (*env)->DeleteLocalRef(env, ba); >+ >+ return s; >+} >+ >+void setClasspath(JNIEnv* jenv, const char* classpath) { >+ jclass clsSystem = NULL; >+ jmethodID mthGetProp = NULL; >+ jmethodID mthSetProp = NULL; >+ jobject obj = NULL; >+ jstring prop, jcp; >+ jthrowable exc; >+ char *cp0, *cp; >+ >+ if (classpath == NULL) return; >+ if (strlen(classpath) <= 0) return; >+ >+ clsSystem = (*jenv)->FindClass(jenv, "java/lang/System"); >+ if (clsSystem == NULL) return; >+ >+ mthGetProp = (*jenv)->GetStaticMethodID(jenv, clsSystem, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;"); >+ if (mthGetProp == NULL) return; >+ >+ mthSetProp = (*jenv)->GetStaticMethodID(jenv, clsSystem, "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); >+ if (mthSetProp == NULL) return; >+ >+ prop = nativeToJavaString(jenv, "java.class.path"); >+ if (prop == NULL) return; >+ >+ jcp = (jstring) (*jenv)->CallStaticObjectMethod(jenv, clsSystem, mthGetProp, prop); >+ if (jcp == NULL) return; >+ >+ cp0 = JavaToNativeString(jenv, jcp); >+ if (cp0 == NULL) { >+ cp = (char*) classpath; >+ } >+ else { >+ int len = strlen(cp0); >+ cp = (char*) malloc(len + strlen(classpath) + 2); // including path separator >+ strcpy(cp, cp0); >+ *(cp + len) = PATH_SEPARATOR; >+ *(cp + len + 1) = '\0'; >+ strcat(cp, classpath); >+ } >+ >+ jcp = nativeToJavaString(jenv, cp); >+ if (jcp != NULL) { >+ (*jenv)->CallStaticObjectMethod(jenv, clsSystem, mthSetProp, prop, jcp); >+ >+ exc = (*jenv)->ExceptionOccurred(jenv); >+ if (exc) { >+ (*jenv)->DeleteLocalRef(jenv, exc); >+ } >+ } >+ >+ if (cp0 != NULL) { >+ free(cp); >+ free(cp0); >+ } >+} >+ >+JavaVM* tptpCreateJVM(const char* classpath) { >+ if (jvm == NULL) >+ createJVM(classpath); >+ else { >+ JNIEnv* jenv; >+ >+ (*jvm)->AttachCurrentThread(jvm, (void**)&jenv, NULL); >+ setClasspath(jenv, classpath); >+ } >+ >+ return jvm; >+} >Index: src-native-new/src/TPTPJava/TPTPJava.def >=================================================================== >RCS file: src-native-new/src/TPTPJava/TPTPJava.def >diff -N src-native-new/src/TPTPJava/TPTPJava.def >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/TPTPJava/TPTPJava.def 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+LIBRARY TPTPJava >+DESCRIPTION "TPTP JVM provider" >+EXPORTS >+ tptpCreateJVM >+ >Index: src-native-new/src/TPTPJava/TPTPJava.make >=================================================================== >RCS file: src-native-new/src/TPTPJava/TPTPJava.make >diff -N src-native-new/src/TPTPJava/TPTPJava.make >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/TPTPJava/TPTPJava.make 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,127 @@ >+ >+################################################################################ >+# >+# makefile: socketTL project >+# >+# $Id: TPTPJava.make,v 1.0 2008/01/17 15:43:07 ialelekov Exp $ >+################################################################################ >+ >+ >+#----------------------------------- >+# >+# Customizable section >+# >+# - The TARGETREALNAME variable specifies the name of the library file >+# that will be generated, this includes a base (TARGETLIB) plus a >+# version number plus a minor number plus a release number >+# - The TARGETSONAME variable specifies a file name that has just the >+# library name plus the major version number >+# - The TARGETLIB variable specifies the base library name >+# - The TARGETSONAME and TARGETLIB are generated as symbolic links >+# when the library is built >+# >+#----------------------------------- >+TARGET := libtptpJava >+TARGETDIR := ../../lib >+ >+if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi >+if [ x$MINORNUM = x ]; then export MINORNUM=0; fi >+if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi >+ >+TARGETLIB := $(TARGET).so >+TARGETSONAME := $(TARGETLIB).$(VERSIONNUM) >+TARGETREALNAME := $(TARGETSONAME).$(MINORNUM).$(RELEASENUM) >+ >+ >+#----------------------------------- >+# list of additional INCLUDE directories to search headers from >+# (separated by blanks) >+#----------------------------------- >+INCLUDEDIRS := . ../../include >+ >+ >+#----------------------------------- >+# list of additional libraries to be linked with >+# (separated by blanks) >+#----------------------------------- >+LIBS := dl tptpConfig >+ >+#----------------------------------- >+# list of additional library directories to search from >+# (separated by blanks) >+#----------------------------------- >+LIBDIRS := ../../lib >+ >+ >+#----------------------------------- >+# >+# Compiler options >+# >+# -g produce debug info >+# -Wall enable all types of warnings >+# -O3 highest level of code optimization >+# -fPIC generate position-independent code (PIC). >+# This is required for building shared library. >+# -c compile only >+# >+# Linking options >+# >+# -Wl pass options to linker >+# -shared produce shared library >+# -L add the given directory to the search path for libraries >+# >+#----------------------------------- >+ >+CFLAGS := $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS)) -D_LINUX_X86 >+ >+CXXFLAGS := $(CFLAGS) >+ >+LINKOPTS := $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS)) >+ >+ >+#----------------------------------- >+# general commands and options >+#----------------------------------- >+ >+CC := gcc >+CXX := $(CC) >+ >+SOURCE := $(wildcard *.c) $(wildcard *.cpp) >+ >+OBJS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE))) >+ >+REMOVEFILE := rm -f >+CREATELINK := ln -sf >+ >+ >+#----------------------------------- >+# "make" rules >+#----------------------------------- >+ >+.PHONY : default everything objs clean veryclean rebuild $(TARGET) >+ >+ >+default : $(TARGET) >+ >+ >+objs : $(OBJS) >+ >+ >+clean : >+ $(REMOVEFILE) *.o >+ >+ >+veryclean: clean >+ $(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB) >+ $(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME) >+ $(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME) >+ >+ >+rebuild: veryclean everything >+ >+ >+$(TARGET) : $(OBJS) >+ $(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS)) >+ $(CREATELINK) $(TARGETREALNAME) $(TARGETDIR)/$(TARGETSONAME) >+ $(CREATELINK) $(TARGETSONAME) $(TARGETDIR)/$(TARGETLIB) >+ >Index: src-native-new/include/tptp/TPTPJava.h >=================================================================== >RCS file: src-native-new/include/tptp/TPTPJava.h >diff -N src-native-new/include/tptp/TPTPJava.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/include/tptp/TPTPJava.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Intel Corporation, IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * $Id: TPTPJava.h,v 1.0 2008/01/17 03:35:47 ialelekov Exp $ >+ *******************************************************************************/ >+ >+#ifndef _TPTP_JAVA_H >+#define _TPTP_JAVA_H >+ >+#include <jni.h> >+ >+#define AC_CONFIG_NOT_FOUND -1 >+#define JVM_LIB_NOT_SET -2 >+#define JVM_LOAD_ERROR -3 >+#define JVM_RESOLVE_ERROR -4 >+#define JVM_CREATION_ERROR -4 >+ >+extern JavaVM* tptpCreateJVM(const char* classpath); >+ >+#endif >Index: src-native-new/src/TPTPJava/TPTPJava.dsp >=================================================================== >RCS file: src-native-new/src/TPTPJava/TPTPJava.dsp >diff -N src-native-new/src/TPTPJava/TPTPJava.dsp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/TPTPJava/TPTPJava.dsp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+# Microsoft Developer Studio Project File - Name="TPTPJava" - Package Owner=<4> >+# Microsoft Developer Studio Generated Build File, Format Version 6.00 >+# ** DO NOT EDIT ** >+ >+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 >+ >+CFG=TPTPJava - Win32 Debug >+!MESSAGE This is not a valid makefile. To build this project using NMAKE, >+!MESSAGE use the Export Makefile command and run >+!MESSAGE >+!MESSAGE NMAKE /f "TPTPJava.mak". >+!MESSAGE >+!MESSAGE You can specify a configuration when running NMAKE >+!MESSAGE by defining the macro CFG on the command line. For example: >+!MESSAGE >+!MESSAGE NMAKE /f "TPTPJava.mak" CFG="TPTPJava - Win32 Debug" >+!MESSAGE >+!MESSAGE Possible choices for configuration are: >+!MESSAGE >+!MESSAGE "TPTPJava - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE "TPTPJava - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE >+ >+# Begin Project >+# PROP AllowPerConfigDependencies 0 >+# PROP Scc_ProjName "" >+# PROP Scc_LocalPath "" >+CPP=cl.exe >+MTL=midl.exe >+RSC=rc.exe >+ >+!IF "$(CFG)" == "TPTPJava - Win32 Release" >+ >+# PROP BASE Use_MFC 0 >+# PROP BASE Use_Debug_Libraries 0 >+# PROP BASE Output_Dir "Release" >+# PROP BASE Intermediate_Dir "Release" >+# PROP BASE Target_Dir "" >+# PROP Use_MFC 0 >+# PROP Use_Debug_Libraries 0 >+# PROP Output_Dir "../../bin" >+# PROP Intermediate_Dir "Release" >+# PROP Ignore_Export_Lib 0 >+# PROP Target_Dir "" >+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /Yu"stdafx.h" /FD /c >+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /FD /c >+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 >+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 >+# ADD BASE RSC /l 0x419 /d "NDEBUG" >+# ADD RSC /l 0x419 /d "NDEBUG" >+BSC32=bscmake.exe >+# ADD BASE BSC32 /nologo >+# ADD BSC32 /nologo >+LINK32=link.exe >+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 >+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpConfig.lib /nologo /dll /machine:I386 /def:".\TPTPJava.def" /implib:"../../lib/TPTPJava.lib" /libpath:"../../lib" >+# SUBTRACT LINK32 /pdb:none >+ >+!ELSEIF "$(CFG)" == "TPTPJava - Win32 Debug" >+ >+# PROP BASE Use_MFC 0 >+# PROP BASE Use_Debug_Libraries 1 >+# PROP BASE Output_Dir "Debug" >+# PROP BASE Intermediate_Dir "Debug" >+# PROP BASE Target_Dir "" >+# PROP Use_MFC 0 >+# PROP Use_Debug_Libraries 1 >+# PROP Output_Dir "../../bin" >+# PROP Intermediate_Dir "Debug" >+# PROP Ignore_Export_Lib 0 >+# PROP Target_Dir "" >+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /Yu"stdafx.h" /FD /GZ /c >+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /FD /GZ /c >+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 >+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 >+# ADD BASE RSC /l 0x419 /d "_DEBUG" >+# ADD RSC /l 0x419 /d "_DEBUG" >+BSC32=bscmake.exe >+# ADD BASE BSC32 /nologo >+# ADD BSC32 /nologo >+LINK32=link.exe >+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept >+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpConfig.lib /nologo /dll /debug /machine:I386 /implib:"../../lib/tptpJava.lib" /pdbtype:sept /libpath:"../../lib" >+# SUBTRACT LINK32 /pdb:none >+ >+!ENDIF >+ >+# Begin Target >+ >+# Name "TPTPJava - Win32 Release" >+# Name "TPTPJava - Win32 Debug" >+# Begin Group "Source Files" >+ >+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" >+# Begin Source File >+ >+SOURCE=.\TPTPJava.c >+# End Source File >+# Begin Source File >+ >+SOURCE=.\TPTPJava.def >+ >+!IF "$(CFG)" == "TPTPJava - Win32 Release" >+ >+# PROP Exclude_From_Build 1 >+ >+!ELSEIF "$(CFG)" == "TPTPJava - Win32 Debug" >+ >+!ENDIF >+ >+# End Source File >+# End Group >+# Begin Group "Header Files" >+ >+# PROP Default_Filter "h;hpp;hxx;hm;inl" >+# End Group >+# End Target >+# End Project
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 215346
:
87013
|
87014
| 87151