From: <or...@us...> - 2015-05-10 20:58:09
|
Revision: 283 http://sourceforge.net/p/bsf4oorexx/code/283 Author: orexx Date: 2015-05-10 20:58:05 +0000 (Sun, 10 May 2015) Log Message: ----------- 20150510 Misc. changes, additions; preparing JSR-223 support. Modified Paths: -------------- trunk/bsf4oorexx.dev/ToDo.txt trunk/bsf4oorexx.dev/bin/BSF.CLS trunk/bsf4oorexx.dev/changesBSF4ooRexx.txt trunk/bsf4oorexx.dev/install/windows/kickoff.rex trunk/bsf4oorexx.dev/source_cc/32/BSF4ooRexx.dll trunk/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc trunk/bsf4oorexx.dev/source_cc/org_rexxla_bsf_engines_rexx_RexxAndJava.h trunk/bsf4oorexx.dev/source_java/RexxAndJava$1.class trunk/bsf4oorexx.dev/source_java/RexxAndJava$2.class trunk/bsf4oorexx.dev/source_java/RexxAndJava$ExitDelayed.class trunk/bsf4oorexx.dev/source_java/RexxAndJava$SyncPutGet.class trunk/bsf4oorexx.dev/source_java/RexxAndJava.class trunk/bsf4oorexx.dev/source_java/RexxAndJava.java trunk/bsf4oorexx.dev/source_java/RexxEngine.class trunk/bsf4oorexx.dev/source_java/RexxEngine.java trunk/bsf4oorexx.dev/source_java/RexxExtendClass.class trunk/bsf4oorexx.dev/source_java/Test.class trunk/bsf4oorexx.dev/source_java/org_rexxla_bsf_engines_rexx_RexxAndJava.h trunk/bsf4oorexx.dev/utilities/ooRexxTry.rxj Modified: trunk/bsf4oorexx.dev/ToDo.txt =================================================================== --- trunk/bsf4oorexx.dev/ToDo.txt 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/ToDo.txt 2015-05-10 20:58:05 UTC (rev 283) @@ -1,3 +1,26 @@ +2014, ---rgf: + + - Re-change method resolution (but make sure that default interface methods of Java 8 get resolved) + + - make sure that protected methods in superclasses get resolved, when method + is not available in current class + + - Make sure that protected fields in superclasses get resolved, when field is not + available in current class + + - Supplier.java / also in ArrayWrapper.java? + + - work on all Java collection patterns! + + - allow any collection to be wrapped as an array ? + + - allow at least to supply a "makearray", resp. create an own MakeArray.java ? + maybe different something like EnumerationWrapper.java for all enumeration + patterns in Java collections ? + +----------------------------- + + - Eventually use Apache Maven to create the binaries (http://maven.apache.org/) - Once ooRexx debugging and profiling is available in the kernel Modified: trunk/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- trunk/bsf4oorexx.dev/bin/BSF.CLS 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/bin/BSF.CLS 2015-05-10 20:58:05 UTC (rev 283) @@ -9,9 +9,14 @@ last change: $Revision: 927 $ $Author: Administrator $ $Date: 2010-12-26 18:34:19 +0100 (Sun, 26 Dec 2010) $ - needs: ooRexx 4.0.1 (cf. <http://www.ooRexx.org>) and BSF4ooRexx 4.0 or greater + needs: ooRexx 4.1.0 (cf. <http://www.ooRexx.org>) and BSF4ooRexx 4.0 or greater date: + 2015-05-10, rgf: - changed BSF_ARRAY_REFERENCE's MAKEARRAY and AT method such that RexxProxy + entries in the Java array get replaced by their contained Rexx object + 2015-05-04, rgf: - corrected minimum ooRexx version to 4.1.0 (determined by BSF4ooRexx.cc) + 2015-05-02, rgf: - make sure in bsf.OutputStream that flush() is used to force the buffered + chars to be displayed for Writers and PrintStreams 2014-10-07, rgf: - JSOasUtf8string: render Java String as UTF-8 encoded Rexx string - utf8stringAsJSO: render UTF-8 Rexx encoded string as a Java String 2014-10-06, rgf: - utf8toString - handle Javs objects @@ -388,7 +393,7 @@ - version: 4.50 (20141014) + version: 4.51 (20150510) authors: (c) 2001-2014 Rony G. Flatscher, University of Augsburg, University of Essen, WU (pronounced: "vey-uh") Vienna; @@ -440,7 +445,7 @@ signal on syntax parse version v . - minimumVersion="4.0.1" -- minimum ooRexx version + minimumVersion="4.2.0" -- minimum ooRexx version (same as BSF4ooRexx.cc) if v < "REXX-ooRexx_"||minimumVersion then do parse source s . name -- extract name of this module @@ -477,7 +482,7 @@ call initialize.BSF.dir -- set up .bsf4rexx and its synonym .b4r - .bsf4rexx~version="450.20141014" -- set version (date distribution got created) + .bsf4rexx~version="451.20150510" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase @@ -2507,9 +2512,15 @@ call bsf "arrayPut", indexArray, tmpArr[i]-1, i-1 end + -- 2015-05-10: special AT processing: if an element is a RexxProxy then replace it + -- with its contained Rexx object; needed for JSR223-eval() implementation + entry=bsf('arrayAt', self~objectName, indexArray) -- get entry from Java array + res=bsf.wrap(entry) + if pos("<O>org.rexxla.bsf.engines.rexx.RexxProxy@",entry)>0 then -- a RexxProxy in hand? + res=BsfRexxProxy(res,"o") -- special AT processing: replace RexxProxy with its contained Rexx object + return res + -- return bsf.wrap( bsf('arrayAt', self~objectName, indexArray)) - return bsf.wrap( bsf('arrayAt', self~objectName, indexArray)) - any: /* if a Java error, then the Java error message/stack trace is stored in the current scope with a variable named "BSF_ERROR_MESSAGE"; in order to make @@ -2683,8 +2694,14 @@ rexxArr=.array~new do i=1 to bsf('arrayLength', arr)~substr(4) -- get length of 'dimensions' array - -- rexxArr[i]=bsf('arrayAt', arr, i-1) -- use Java indexing (starting with '0') - rexxArr[i]=bsf.wrap(bsf('arrayAt', arr, i-1)) -- use Java indexing (starting with '0') + -- rexxArr[i]=bsf.wrap(bsf('arrayAt', arr, i-1)) -- use Java indexing (starting with '0') + -- 2015-05-10: special MAKEARRAY processing: if an element is a RexxProxy then replace it + -- with its contained Rexx object; needed for JSR223-eval() implementation + entry=bsf('arrayAt', arr, i-1) + rexxArr[i]=bsf.wrap(entry) -- use Java indexing (starting with '0') + if pos("<O>org.rexxla.bsf.engines.rexx.RexxProxy@",entry)>0 then -- a RexxProxy in hand? + rexxArr[i]=BsfRexxProxy(rexxArr[i],"o") -- special MAKEARRAY processing: replace RexxProxy with its contained Rexx object + end return rexxArr @@ -4196,11 +4213,10 @@ iterate if char="0a"x then -- received LF, return chars gathered so far - return mb~string + return mb~string -- return collected characters mb~append(char) end - return mb~string /* Allows to use a java.io.PrintStream or a java.io.Writer object as an ooRexx output stream. */ @@ -4232,6 +4248,7 @@ else javaOutputObject~print(chars~subStr(start)) end + javaOutputObject~flush -- make sure buffer gets flushed (otherwise we may not see any output) ::method lineOut expose javaOutputObject isWriter @@ -4246,7 +4263,8 @@ do javaOutputObject~println(chars) end + javaOutputObject~flush -- make sure buffer gets flushed (otherwise we may not see any output) -::method say -- in ooRexx file streams a synonym for lineOut +::method say -- in ooRexx file streams a synonym for lineOut forward message "lineout" Modified: trunk/bsf4oorexx.dev/changesBSF4ooRexx.txt =================================================================== --- trunk/bsf4oorexx.dev/changesBSF4ooRexx.txt 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/changesBSF4ooRexx.txt 2015-05-10 20:58:05 UTC (rev 283) @@ -1,3 +1,9 @@ +-------------------------------------- 2014-12-12 ---------------------------------- + +- install\windows\kickoff.rex + - use fully qualified path to "install" directory as some versions of + Windows will change the current directory after elevation + -------------------------------------- 2014-10-07 ---------------------------------- - BSF.CLS Modified: trunk/bsf4oorexx.dev/install/windows/kickoff.rex =================================================================== --- trunk/bsf4oorexx.dev/install/windows/kickoff.rex 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/install/windows/kickoff.rex 2015-05-10 20:58:05 UTC (rev 283) @@ -8,10 +8,13 @@ an error, just runs it without; this way starting with Windows2000/XP elevation is attempted, the fallback is to run re/un/installation as is - Version: 1.01 + Version: 1.02 Changes: - 2014-04-26 rgf: use "elevate{32|64}.exe" on Windows Vista and higher to run the [re|un]install elevated + - 2014-12-12 rgf: use fully qualified path to setupAllAndRun.rex as elevation + may change the current directory to the Windows home directory + Info-URLs: <http://technet.microsoft.com/en-us/magazine/2007.06.utilityspotlight.aspx> <http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx> <http://forums.techarena.in/vista-administration/977482.htm> @@ -98,8 +101,8 @@ say "===>" -- rexxExe = quote( qualify( value("REXX_HOME",,"ENVIRONMENT")"\rexx.exe" ) ) rexxExe = "rexx.exe" -- will be found along the path --- setupScript = quote( qualify(workDir"\..\setupAllAndRun.rex") ) -- fully qualify script - setupScript = "..\setupAllAndRun.rex" -- fully qualify script + setupScript = quote( qualify(workDir"\..\setupAllAndRun.rex") ) -- fully qualify script +-- setupScript = "..\setupAllAndRun.rex" -- unqualify script rexxBits=getRexxBitness() elevateExe = "Elevate"rexxBits".exe" mode="Elevate"rexxBits".exe" Modified: trunk/bsf4oorexx.dev/source_cc/32/BSF4ooRexx.dll =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc =================================================================== --- trunk/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2015-05-10 20:58:05 UTC (rev 283) @@ -24,6 +24,14 @@ * * last change: $Revision: 888 $ $Author: Administrator $ $Date: 2010-08-16 16:02:21 +0200 (Mon, 16. Aug 2010) $ + 4.5.1 2015-05-09, - rgf: added JNI methods that allow a RexxEngine.java instance to get information aobut it + - _RexxAndJava_jniGetGlobalEnvironment0 ... .environment + - _RexxAndJava_jniGetLocalEnvironment0 ... .local + - _RexxAndJava_jniNil0 ... .nil + - _RexxAndJava_jniInterpreterVersion0 ... least signifant three bytes encode this information + - _RexxAndJava_jniLanguageVersion0 ... least signifant two bytes encode this information + + 4.5.0 2014-10-20, - rgf: updated package information in RexxPackageEntry structure 4.5.0 2014-05-17, - simplified attaching/detaching to the JVM, a side effect will be a slight performance improvement (appr. 5%) - replace deprecated BSFAttachToTID() and BSFDetach() with body that always returns true @@ -590,7 +598,11 @@ // #define DEBUG_SEND_MESSAGE_TO_REXX_OBJECT // 2009-09-06 // #define DEBUG_RGF_PROCESS_J_ARGS // 2009-09-06 +// #define DEBUG_RGF_PROCESS_J_ARG1 // rgf, 2012-02-07; renamed to RgfJavaObject2RexxObject, 2012-02-18 +// #define DEBUG_ARRAY_ARGS +// #define DEBUG_ARRAY_ARGS // rgf, 2012-02-21 + // #define DEBUG_SHOW_STRUCTURES // ---rgf, 2009-10-06 // #define DEBUG_JAVA_ATTACH_DETACH // ---rgf, 2009-10-07 @@ -854,11 +866,11 @@ #if defined (BSF4REXX_32_BIT) - #define BSF_VERSION "450.20140518 org/rexxla/bsf/engines/rexx 32-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "451.20150509 org/rexxla/bsf/engines/rexx 32-bit" // version: "MajorNumber"."YYYYMMDD" #elif defined (BSF4REXX_64_BIT) - #define BSF_VERSION "450.20140518 org/rexxla/bsf/engines/rexx 64-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "451.20150509 org/rexxla/bsf/engines/rexx 64-bit" // version: "MajorNumber"."YYYYMMDD" #else - #define BSF_VERSION "450.20140518 org/rexxla/bsf/engines/rexx n/a-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "451.20150509 org/rexxla/bsf/engines/rexx n/a-bit" // version: "MajorNumber"."YYYYMMDD" #endif #define JAVA_4_REXX "org/rexxla/bsf/engines/rexx/Java4Rexx" // 2005-06-02, supportive Java4Rexx-class @@ -10989,7 +11001,7 @@ STANDARD_PACKAGE_HEADER REXX_INTERPRETER_4_1_0, // anything including and after 4.1.0 will work "bsf", // name of the package - "4.1", // package information + "4.5", // package version information bsfLoader, // no load function bsfUnloader, // no unload function bsf_external_functions, // the exported functions @@ -12327,12 +12339,16 @@ fflush(stderr); #endif -// fprintf(stderr, "...jniRexxSendMessageToRexxObject(): BEFORE SendMessage(), ro=[%p], c_msg=[%.256s], ra=[%p], size=[%u]...\n",ro, c_msg, ra, rtc->ArraySize(ra));fflush(stderr); +#if defined (DEBUG_SEND_MESSAGE_TO_REXX_OBJECT) + fprintf(stderr, "...jniRexxSendMessageToRexxObject(): BEFORE SendMessage(), ro=[%p], c_msg=[%.256s], ra=[%p], size=[%u]...\n",ro, c_msg, ra, rtc->ArraySize(ra));fflush(stderr); +#endif result_obj=rtc->SendMessage(ro, c_msg, ra); // with arguments // rgf, 201310 rtc->ReleaseLocalReference(ra); -// fprintf(stderr, "...jniRexxSendMessageToRexxObject(): AFTER SendMessage(),...\n");fflush(stderr); +#if defined (DEBUG_SEND_MESSAGE_TO_REXX_OBJECT) + fprintf(stderr, "...jniRexxSendMessageToRexxObject(): AFTER SendMessage(),...\n");fflush(stderr); +#endif #if defined (RGF_TRUE) || defined (DEBUG_40) || defined (DEBUG_REXX_PROXY) || defined (DEBUG_SEND_MESSAGE_TO_REXX_OBJECT) fprintf(stderr, "...jniRexxSendMessageToRexxObject(): thisTid=[%lu]... SendMessage: c_msg=[%.256s], ra=[%p], size=[%u]; result_obj=[%p] ...\n", @@ -15543,7 +15559,676 @@ } +// ------ 2015-05-09, rgf +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniGetLocalEnvironment0 + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniGetLocalEnvironment0 + // (JNIEnv *, jobject, jstring); + (JNIEnv *env, jobject raj, jstring j_rii_ID) +{ +#ifdef UNIX + pthread_t +#else // WIN32 + TID +#endif + tid=RgfGetTID(); // get current TID + +#if defined(DEBUG_JNI) || defined (DEBUG40) || defined (DEBUG_JNI_ENTRY) + fprintf(stderr, "--> arrived: ..._jniGetLocalEnvironment(), tid=[%lu], currentJVM=[%p], defaultJVM->jvm=[%p], defaultJVM->clz_Object=[%p]\n", + (unsigned long) tid, currentJVM, defaultJVM->jvm, defaultJVM->clz_Object); + fprintf(stderr, "\t\tenv=[%p], raj=[%p], j_rii_ID=[%p]\n", env, raj, j_rii_ID); + fflush(stderr); +#endif + + // get interpreter instance from argument + char *c_rii_ID=NULL; + RexxInstance *instance=NULL; + c_rii_ID=(char *) JNU_GetStringNativeChars(env, j_rii_ID); // convert to native string + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, " using c_rii_ID=[%.256s]\n", c_rii_ID); + fflush(stderr); +#endif + + RgfString2Pointer(c_rii_ID, instance); // get pointer from string + RexxFreeMemory(c_rii_ID); + + RexxThreadContext *rtc=NULL; + RexxObjectPtr result_obj; // Rexx object returned from Rexx, NULL[OBJECT], if none + + RexxInstance *tmpInstance=NULL; + tmpInstance=RgfGetRexxInterpreterInstanceFromList(instance); // try to get given Rexx Interpreter instance + + if (instance != tmpInstance) // error (do not halt another Rexx Interpreter instance!) + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/jniGetLocalEnvironment(), error 1: Rexx interpreter instance with the ID '%p' could not be found", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_INVALID_ARGUMENT, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniGetLocalEnvironment(): tid=[%lu], error, cannot retrieve c_rii_ID=p=[%p], received=tmpInstance=[%p] instead\n", + (unsigned long) tid, instance, tmpInstance); + fflush(stderr); +#endif + + return NULL; + } + + // no need to do a rtc->ReleaseLocalReference(ro) as these references get released upon rtc->DetachThread() ! + if (!instance->AttachThread(&rtc)) // get a ThreadContext + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/jniGetLocalEnvironment(), error 2: could not AttachThread() to Rexx interpreter instance with the ID '%p'", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniGetLocalEnvironment(): tid=[%lu], error, cannot do an instance->AttachThread()!\n", + (unsigned long) tid); + fflush(stderr); +#endif + + return NULL; + } + + result_obj=rtc->GetLocalEnvironment(); // get local environment + + // check for exception; if so, create RexxException, supply condition object as a RexxProxy; clear exception in thread + if (rtc->CheckCondition()) // a Rexx condition raised? + { + RexxDirectoryObject condObj=rtc->GetConditionInfo(); + char * msg=RgfCreateRexxlikeErrorInfo (rtc, condObj, "/routine/jniRexxRunProgram(), error 9"); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + rtc, // rtc, + condObj, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + rtc->DetachThread(); + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniGetLocalEnvironment(): tid=[%lu], Rexx runtime error occurred, throwing Java exception!\n\tmsg=[%.256s]\n", + (unsigned long) tid, msg); + fflush(stderr); +#endif + + RexxFreeMemory(msg); + return NULL; + } + + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning from: .._jniRexxRunProgram(...), tid=[%lu], normal execution\n", (unsigned long) tid); + fflush(stderr); +#endif + + jobject jresult=RgfProcessReturnValue4Java(env, raj, rtc, result_obj, NULL); + + rtc->DetachThread(); + + return jresult; +} + +// ------ > neu! + +// ---------- neuer + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniGetGlobalEnvironment0 + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniGetGlobalEnvironment0 + // (JNIEnv *, jobject, jstring); + (JNIEnv *env, jobject raj, jstring j_rii_ID) +{ +#ifdef UNIX + pthread_t +#else // WIN32 + TID +#endif + tid=RgfGetTID(); // get current TID + +#if defined(DEBUG_JNI) || defined (DEBUG40) || defined (DEBUG_JNI_ENTRY) + fprintf(stderr, "--> arrived: ..._jniGetGlobalEnvironment0(), tid=[%lu], currentJVM=[%p], defaultJVM->jvm=[%p], defaultJVM->clz_Object=[%p]\n", + (unsigned long) tid, currentJVM, defaultJVM->jvm, defaultJVM->clz_Object); + fprintf(stderr, "\t\tenv=[%p], raj=[%p], j_rii_ID=[%p]\n", env, raj, j_rii_ID); + fflush(stderr); +#endif + + // get interpreter instance from argument + char *c_rii_ID=NULL; + RexxInstance *instance=NULL; + c_rii_ID=(char *) JNU_GetStringNativeChars(env, j_rii_ID); // convert to native string + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, " using c_rii_ID=[%.256s]\n", c_rii_ID); + fflush(stderr); +#endif + + RgfString2Pointer(c_rii_ID, instance); // get pointer from string + RexxFreeMemory(c_rii_ID); + + RexxThreadContext *rtc=NULL; + RexxObjectPtr result_obj; // Rexx object returned from Rexx, NULL[OBJECT], if none + + RexxInstance *tmpInstance=NULL; + tmpInstance=RgfGetRexxInterpreterInstanceFromList(instance); // try to get given Rexx Interpreter instance + + if (instance != tmpInstance) // error (do not halt another Rexx Interpreter instance!) + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/jniGetGlobalEnvironment0(), error 1: Rexx interpreter instance with the ID '%p' could not be found", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_INVALID_ARGUMENT, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniGetGlobalEnvironment0(): tid=[%lu], error, cannot retrieve c_rii_ID=p=[%p], received=tmpInstance=[%p] instead\n", + (unsigned long) tid, instance, tmpInstance); + fflush(stderr); +#endif + + return NULL; + } + + // no need to do a rtc->ReleaseGlobalReference(ro) as these references get released upon rtc->DetachThread() ! + if (!instance->AttachThread(&rtc)) // get a ThreadContext + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/jniGetGlobalEnvironment0(), error 2: could not AttachThread() to Rexx interpreter instance with the ID '%p'", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniGetGlobalEnvironment0(): tid=[%lu], error, cannot do an instance->AttachThread()!\n", + (unsigned long) tid); + fflush(stderr); +#endif + + return NULL; + } + + result_obj=rtc->GetGlobalEnvironment(); // get Global environment + + // check for exception; if so, create RexxException, supply condition object as a RexxProxy; clear exception in thread + if (rtc->CheckCondition()) // a Rexx condition raised? + { + RexxDirectoryObject condObj=rtc->GetConditionInfo(); + char * msg=RgfCreateRexxlikeErrorInfo (rtc, condObj, "/routine/jniRexxRunProgram(), error 9"); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + rtc, // rtc, + condObj, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + rtc->DetachThread(); + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniGetGlobalEnvironment0(): tid=[%lu], Rexx runtime error occurred, throwing Java exception!\n\tmsg=[%.256s]\n", + (unsigned long) tid, msg); + fflush(stderr); +#endif + + RexxFreeMemory(msg); + return NULL; + } + + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning from: .._jniRexxRunProgram(...), tid=[%lu], normal execution\n", (unsigned long) tid); + fflush(stderr); +#endif + + jobject jresult=RgfProcessReturnValue4Java(env, raj, rtc, result_obj, NULL); + + rtc->DetachThread(); + + return jresult; + +} + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniNil0 + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniNil0 + // (JNIEnv *, jobject, jstring); + (JNIEnv *env, jobject raj, jstring j_rii_ID) +{ +#ifdef UNIX + pthread_t +#else // WIN32 + TID +#endif + tid=RgfGetTID(); // get current TID + +#if defined(DEBUG_JNI) || defined (DEBUG40) || defined (DEBUG_JNI_ENTRY) + fprintf(stderr, "--> arrived: ..._jniNil0(), tid=[%lu], currentJVM=[%p], defaultJVM->jvm=[%p], defaultJVM->clz_Object=[%p]\n", + (unsigned long) tid, currentJVM, defaultJVM->jvm, defaultJVM->clz_Object); + fprintf(stderr, "\t\tenv=[%p], raj=[%p], j_rii_ID=[%p]\n", env, raj, j_rii_ID); + fflush(stderr); +#endif + + // get interpreter instance from argument + char *c_rii_ID=NULL; + RexxInstance *instance=NULL; + c_rii_ID=(char *) JNU_GetStringNativeChars(env, j_rii_ID); // convert to native string + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, " using c_rii_ID=[%.256s]\n", c_rii_ID); + fflush(stderr); +#endif + + RgfString2Pointer(c_rii_ID, instance); // get pointer from string + RexxFreeMemory(c_rii_ID); + + RexxThreadContext *rtc=NULL; + RexxObjectPtr result_obj; // Rexx object returned from Rexx, NULL[OBJECT], if none + + RexxInstance *tmpInstance=NULL; + tmpInstance=RgfGetRexxInterpreterInstanceFromList(instance); // try to get given Rexx Interpreter instance + + if (instance != tmpInstance) // error (do not halt another Rexx Interpreter instance!) + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/jniNil0(), error 1: Rexx interpreter instance with the ID '%p' could not be found", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_INVALID_ARGUMENT, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniNil0(): tid=[%lu], error, cannot retrieve c_rii_ID=p=[%p], received=tmpInstance=[%p] instead\n", + (unsigned long) tid, instance, tmpInstance); + fflush(stderr); +#endif + + return NULL; + } + + // no need to do a rtc->ReleaseGlobalReference(ro) as these references get released upon rtc->DetachThread() ! + if (!instance->AttachThread(&rtc)) // get a ThreadContext + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/jniNil0(), error 2: could not AttachThread() to Rexx interpreter instance with the ID '%p'", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniNil0(): tid=[%lu], error, cannot do an instance->AttachThread()!\n", + (unsigned long) tid); + fflush(stderr); +#endif + + return NULL; + } + + result_obj=rtc->Nil(); // get .nil + + // check for exception; if so, create RexxException, supply condition object as a RexxProxy; clear exception in thread + if (rtc->CheckCondition()) // a Rexx condition raised? + { + RexxDirectoryObject condObj=rtc->GetConditionInfo(); + char * msg=RgfCreateRexxlikeErrorInfo (rtc, condObj, "/routine/jniRexxRunProgram(), error 9"); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + rtc, // rtc, + condObj, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + rtc->DetachThread(); + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ..._jniNil0(): tid=[%lu], Rexx runtime error occurred, throwing Java exception!\n\tmsg=[%.256s]\n", + (unsigned long) tid, msg); + fflush(stderr); +#endif + + RexxFreeMemory(msg); + return NULL; + } + + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning from: .._jniRexxRunProgram(...), tid=[%lu], normal execution\n", (unsigned long) tid); + fflush(stderr); +#endif + + // make sure that we explicitly return a RexxProxy with .nil embedded! + jobject jresult=RgfCreateRexxProxy(env, raj, rtc, result_obj, NULL, NULL); + + rtc->DetachThread(); + + return jresult; +} + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniInterpreterVersion0 + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniInterpreterVersion0 + // (JNIEnv *, jobject, jstring); + (JNIEnv *env, jobject raj, jstring j_rii_ID) +{ +#ifdef UNIX + pthread_t +#else // WIN32 + TID +#endif + tid=RgfGetTID(); // get current TID + +#if defined(DEBUG_JNI) || defined (DEBUG40) || defined (DEBUG_JNI_ENTRY) + fprintf(stderr, "--> arrived: ...__jniInterpreterVersion0(), tid=[%lu], currentJVM=[%p], defaultJVM->jvm=[%p], defaultJVM->clz_Object=[%p]\n", + (unsigned long) tid, currentJVM, defaultJVM->jvm, defaultJVM->clz_Object); + fprintf(stderr, "\t\tenv=[%p], raj=[%p], j_rii_ID=[%p]\n", env, raj, j_rii_ID); + fflush(stderr); +#endif + + // get interpreter instance from argument + char *c_rii_ID=NULL; + RexxInstance *instance=NULL; + c_rii_ID=(char *) JNU_GetStringNativeChars(env, j_rii_ID); // convert to native string + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, " using c_rii_ID=[%.256s]\n", c_rii_ID); + fflush(stderr); +#endif + + RgfString2Pointer(c_rii_ID, instance); // get pointer from string + RexxFreeMemory(c_rii_ID); + + RexxThreadContext *rtc=NULL; + + RexxInstance *tmpInstance=NULL; + tmpInstance=RgfGetRexxInterpreterInstanceFromList(instance); // try to get given Rexx Interpreter instance + + if (instance != tmpInstance) // error (do not halt another Rexx Interpreter instance!) + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/_jniInterpreterVersion0(), error 1: Rexx interpreter instance with the ID '%p' could not be found", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_INVALID_ARGUMENT, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ...__jniInterpreterVersion0(): tid=[%lu], error, cannot retrieve c_rii_ID=p=[%p], received=tmpInstance=[%p] instead\n", + (unsigned long) tid, instance, tmpInstance); + fflush(stderr); +#endif + + return NULL; + } + + // no need to do a rtc->ReleaseGlobalReference(ro) as these references get released upon rtc->DetachThread() ! + if (!instance->AttachThread(&rtc)) // get a ThreadContext + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/_jniInterpreterVersion0(), error 2: could not AttachThread() to Rexx interpreter instance with the ID '%p'", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ...__jniInterpreterVersion0(): tid=[%lu], error, cannot do an instance->AttachThread()!\n", + (unsigned long) tid); + fflush(stderr); +#endif + + return NULL; + } + + size_t res=rtc->InterpreterVersion(); + + // check for exception; if so, create RexxException, supply condition object as a RexxProxy; clear exception in thread + if (rtc->CheckCondition()) // a Rexx condition raised? + { + RexxDirectoryObject condObj=rtc->GetConditionInfo(); + char * msg=RgfCreateRexxlikeErrorInfo (rtc, condObj, "/routine/jniRexxRunProgram(), error 9"); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + rtc, // rtc, + condObj, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + rtc->DetachThread(); + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ...__jniInterpreterVersion0(): tid=[%lu], Rexx runtime error occurred, throwing Java exception!\n\tmsg=[%.256s]\n", + (unsigned long) tid, msg); + fflush(stderr); +#endif + + RexxFreeMemory(msg); + return NULL; + } + + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning from: ..__jniInterpreterVersion0(), tid=[%lu], normal execution\n", (unsigned long) tid); + fflush(stderr); +#endif + + // make sure that we explicitly return a RexxProxy with .nil embedded! + + rtc->DetachThread(); + + return res; +} + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniLanguageLevel0 + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniLanguageLevel0 + // (JNIEnv *, jobject, jstring); + (JNIEnv *env, jobject raj, jstring j_rii_ID) +{ + +#ifdef UNIX + pthread_t +#else // WIN32 + TID +#endif + tid=RgfGetTID(); // get current TID + +#if defined(DEBUG_JNI) || defined (DEBUG40) || defined (DEBUG_JNI_ENTRY) + fprintf(stderr, "--> arrived: ...__jniLanguageVersion0(), tid=[%lu], currentJVM=[%p], defaultJVM->jvm=[%p], defaultJVM->clz_Object=[%p]\n", + (unsigned long) tid, currentJVM, defaultJVM->jvm, defaultJVM->clz_Object); + fprintf(stderr, "\t\tenv=[%p], raj=[%p], j_rii_ID=[%p]\n", env, raj, j_rii_ID); + fflush(stderr); +#endif + + // get interpreter instance from argument + char *c_rii_ID=NULL; + RexxInstance *instance=NULL; + c_rii_ID=(char *) JNU_GetStringNativeChars(env, j_rii_ID); // convert to native string + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, " using c_rii_ID=[%.256s]\n", c_rii_ID); + fflush(stderr); +#endif + + RgfString2Pointer(c_rii_ID, instance); // get pointer from string + RexxFreeMemory(c_rii_ID); + + RexxThreadContext *rtc=NULL; + + RexxInstance *tmpInstance=NULL; + tmpInstance=RgfGetRexxInterpreterInstanceFromList(instance); // try to get given Rexx Interpreter instance + + if (instance != tmpInstance) // error (do not halt another Rexx Interpreter instance!) + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/_jniLanguageVersion0(), error 1: Rexx interpreter instance with the ID '%p' could not be found", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_INVALID_ARGUMENT, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ...__jniLanguageVersion0(): tid=[%lu], error, cannot retrieve c_rii_ID=p=[%p], received=tmpInstance=[%p] instead\n", + (unsigned long) tid, instance, tmpInstance); + fflush(stderr); +#endif + + return NULL; + } + + // no need to do a rtc->ReleaseGlobalReference(ro) as these references get released upon rtc->DetachThread() ! + if (!instance->AttachThread(&rtc)) // get a ThreadContext + { + char *msg=new char[1024]; + SNPRINTF( msg, 1024, "%.16s/routine/_jniLanguageVersion0(), error 2: could not AttachThread() to Rexx interpreter instance with the ID '%p'", DLLNAME, instance); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + NULL, // rtc, + NULL, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + delete[] msg; + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ...__jniLanguageVersion0(): tid=[%lu], error, cannot do an instance->AttachThread()!\n", + (unsigned long) tid); + fflush(stderr); +#endif + + return NULL; + } + + size_t res=rtc->LanguageLevel(); + + // check for exception; if so, create RexxException, supply condition object as a RexxProxy; clear exception in thread + if (rtc->CheckCondition()) // a Rexx condition raised? + { + RexxDirectoryObject condObj=rtc->GetConditionInfo(); + char * msg=RgfCreateRexxlikeErrorInfo (rtc, condObj, "/routine/jniRexxRunProgram(), error 9"); + + jthrowable j_rexxException=RgfCreateRexxException4Java(env, raj, + rtc, // rtc, + condObj, // conditionObject + // NULL, // packageObject + REASON_EXECUTION_ERROR, // reason + msg // message + ); + rtc->DetachThread(); + env->Throw(j_rexxException); // throw the exception in the JVM + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning: ...__jniLanguageVersion0(): tid=[%lu], Rexx runtime error occurred, throwing Java exception!\n\tmsg=[%.256s]\n", + (unsigned long) tid, msg); + fflush(stderr); +#endif + + RexxFreeMemory(msg); + return NULL; + } + + +#if defined(DEBUG_JNI) || defined (DEBUG40) + fprintf(stderr, "<-- returning from: .._jniLanguageVersion0(), tid=[%lu], normal execution\n", (unsigned long) tid); + fflush(stderr); +#endif + + rtc->DetachThread(); + + return res; +} + + + + + + #ifdef __cplusplus } // closing bracket #endif Modified: trunk/bsf4oorexx.dev/source_cc/org_rexxla_bsf_engines_rexx_RexxAndJava.h =================================================================== --- trunk/bsf4oorexx.dev/source_cc/org_rexxla_bsf_engines_rexx_RexxAndJava.h 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/source_cc/org_rexxla_bsf_engines_rexx_RexxAndJava.h 2015-05-10 20:58:05 UTC (rev 283) @@ -95,6 +95,20 @@ #define org_rexxla_bsf_engines_rexx_RexxAndJava_ENV_GET 42L #undef org_rexxla_bsf_engines_rexx_RexxAndJava_ENV_SET #define org_rexxla_bsf_engines_rexx_RexxAndJava_ENV_SET 43L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_INVOKE_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_INVOKE_JSO 44L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_INVOKE_STRICT_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_INVOKE_STRICT_JSO 45L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_GET_FIELD_VALUE_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_GET_FIELD_VALUE_JSO 46L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_GET_FIELD_VALUE_STRICT_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_GET_FIELD_VALUE_STRICT_JSO 47L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_GET_PROPERTY_VALUE_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_GET_PROPERTY_VALUE_JSO 48L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_GET_STATIC_VALUE_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_GET_STATIC_VALUE_JSO 49L +#undef org_rexxla_bsf_engines_rexx_RexxAndJava_GET_STATIC_VALUE_STRICT_JSO +#define org_rexxla_bsf_engines_rexx_RexxAndJava_GET_STATIC_VALUE_STRICT_JSO 50L /* * Class: org_rexxla_bsf_engines_rexx_RexxAndJava * Method: jniSetupNativeJVMPointer @@ -369,6 +383,46 @@ /* * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniGetLocalEnvironment0 + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniGetLocalEnvironment0 + (JNIEnv *, jobject, jstring); + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniGetGlobalEnvironment0 + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniGetGlobalEnvironment0 + (JNIEnv *, jobject, jstring); + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniNil0 + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniNil0 + (JNIEnv *, jobject, jstring); + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniInterpreterVersion0 + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniInterpreterVersion0 + (JNIEnv *, jobject, jstring); + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava + * Method: jniLanguageLevel0 + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_rexxla_bsf_engines_rexx_RexxAndJava_jniLanguageLevel0 + (JNIEnv *, jobject, jstring); + +/* + * Class: org_rexxla_bsf_engines_rexx_RexxAndJava * Method: jniInitialize4Rexx * Signature: ()I */ Modified: trunk/bsf4oorexx.dev/source_java/RexxAndJava$1.class =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_java/RexxAndJava$2.class =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_java/RexxAndJava$ExitDelayed.class =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_java/RexxAndJava$SyncPutGet.class =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_java/RexxAndJava.class =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_java/RexxAndJava.java =================================================================== --- trunk/bsf4oorexx.dev/source_java/RexxAndJava.java 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/source_java/RexxAndJava.java 2015-05-10 20:58:05 UTC (rev 283) @@ -21,7 +21,7 @@ * * * <pre>------------------------ Apache Version 2.0 license ------------------------- - * Copyright (C) 2001-2014 Rony G. Flatscher + * Copyright (C) 2001-2015 Rony G. Flatscher * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ * limitations under the License. * ----------------------------------------------------------------------------- </pre> * - * @version 4.2.0, 2014-10-05 + * @version 4.2.1, 2015-05-09 * @author Rony G. Flatscher (<a href="http://www.wu-wien.ac.at">WU-Wien/Wirtschaftsuniversität Wien</a>, <a href="http://www.wu-wien.ac.at/english">http://www.wu-wien.ac.at/english</a>) */ @@ -48,6 +48,13 @@ */ /* + 2015-05-09, ---rgf, - added access to important Rexx objects and interpreter related information + - protected native Object jniGetLocalEnvironment0 + - protected native Object jniGetGlobalEnvironment0 + - protected native Object jniNil0 + - protected native long jniInterpreterVersion0 + - protected native long jniLanguageLevel0 + 2014-10-04, ---rgf, - add subfunctions that return a reference to a java.lang.String object or a NetRexx object, if such a value needs to be returned (rather than turning it into a Rexx string), added subfunctions: @@ -319,7 +326,7 @@ /** Version string indicating version of this class (majorVersion*100+minorVersion * concatenated with a dot and the sorted date of last change. */ - static final public String version = "420.20141005"; + static final public String version = "421.20150509"; static final private String pkgName = "org.rexxla.bsf.engines.rexx"; @@ -841,10 +848,12 @@ protected native int jniRexxTerminateInterpreterInstance (String rii_ID); // use Terminate(), but *must* be issued from the original thread context + // ------------------ JNI functions meant to be accessed by Java exit handlers only! + // (these jni functions need a properly set up opaque slot argument!) + // rgf, 2012-02-08, used for allowing exit and command handlers to interact with their RexxExitContext // for raising conditions and querying/setting variables. // - protected native void jniRaiseCondition (Object[] slot, String conditionName, String description, Object[] additional, Object result); protected native void jniRaiseException (Object[] slot, long definedErrorNumber, Object[] substitutions); protected native void jniRaiseException0 (Object[] slot, long definedErrorNumber); @@ -853,7 +862,7 @@ protected native Object jniGetContextVariable(Object[] slot, String variableName); protected native void jniSetContextVariable(Object[] slot, String variableName, Object variableValue); - // rgf, 2012-02-11 + // rgf, 2012-02-11: for RexxHandler access only (these jni functions need a properly set up opaque slot argument!) protected native boolean jniCheckCondition (Object[] slot); protected native void jniClearCondition (Object[] slot); protected native Object jniGetConditionInfo (Object[] slot); @@ -861,30 +870,40 @@ protected native void jniSetThreadTrace (Object[] slot, boolean state); protected native void jniHaltThread (Object[] slot); - // rgf, 2012-02-12 + // rgf, 2012-02-12: for RexxHandler access only (these jni functions need a properly set up opaque slot argument!) protected native void jniDropContextVariable(Object[] slot, String variableName); - // rgf, 2012-02-18 + // rgf, 2012-02-18: for RexxHandler access only (these jni functions need a properly set up opaque slot argument!) protected native void jniSetContextVariableToNil(Object[] slot, String variableName); - // rgf, 2012-02-19 + // rgf, 2012-02-19: for RexxHandler access only (these jni functions need a properly set up opaque slot argument!) protected native Object jniGetCallerContext (Object[] slot); protected native Object jniGetAllContextVariables(Object[] slot); - // rgf, 2012-02-24 + // rgf, 2012-02-24: for RexxHandler access only (these jni functions need a properly set up opaque slot argument!) protected native Object jniGetLocalEnvironment(Object[] slot); protected native Object jniGetGlobalEnvironment(Object[] slot); - - // rgf, 2012-02-25 + // rgf, 2012-02-25: for RexxHandler access only (these jni functions need a properly set up opaque slot argument!) protected native Object jniNil(Object[] slot); protected native long jniInterpreterVersion(Object[] slot); protected native long jniLanguageLevel (Object[] slot); - // rgf, 2014-03-29 protected native String jniProcEnvironment(int function, String envName, String envValue); + // ------------------ allow fetching a few important Rexx objects resp. Rexx interpreter related information + // rgf, 2015-05-09 + protected native Object jniGetLocalEnvironment0 (String rii_ID); + protected native Object jniGetGlobalEnvironment0(String rii_ID); + protected native Object jniNil0 (String rii_ID); + protected native long jniInterpreterVersion0 (String rii_ID); + protected native long jniLanguageLevel0 (String rii_ID); + + + + + /** rgf, 2003-01-15, used for allowing the BSF4ooRexx-DLL to get at *env, *obj and then to mid etc. * */ protected native int jniInitialize4Rexx() ; Modified: trunk/bsf4oorexx.dev/source_java/RexxEngine.class =================================================================== (Binary files differ) Modified: trunk/bsf4oorexx.dev/source_java/RexxEngine.java =================================================================== --- trunk/bsf4oorexx.dev/source_java/RexxEngine.java 2015-05-01 18:29:08 UTC (rev 282) +++ trunk/bsf4oorexx.dev/source_java/RexxEngine.java 2015-05-10 20:58:05 UTC (rev 283) @@ -14,7 +14,7 @@ * using the RexxSAA interface. * * <pre>------------------------ Apache Version 2.0 license ------------------------- - * Copyright (C) 2001-2014 Rony G. Flatscher + * Copyright (C) 2001-2015 Rony G. Flatscher * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ * limitations under the License. * ----------------------------------------------------------------------------- </pre> * - * @version 4.5.0, 20140703 + * @version 4.5.1, 20150509 * @author Rony G. Flatscher (<a href="http://www.wu-wien.ac.at">WU-Wien/Wirtschaftsuniversität Wien</a>, <a href="http://www.wu-wien.ac.at/english">http://www.wu-wien.ac.at/english</a>) * */ @@ -37,6 +37,13 @@ /* last change: $Revision: 546 $ $Author: rony $ $Date: 2009-10-20 20:45:19 +0200 (Tue, 20 Oct 2009) $ + 2015-05-09, ---rgf, - added public methods + - getLocalEnvironment() ... returns .local + - getPublicEnvironment() ... returns .environment + - getNil() ... returns .nil + - getInterpreterVersion() ... returns long, where the least significant three bytes contain the version encoded + - getLanguageVersion() ... returns long, where the least significant two bytes contain the version encoded + 2014-07-03, ---rgf, - make sure that RexxProxy objects are always passed as Java objects in arguments; adapt apply() as well to pass through RexxProxy objects in arguments @@ -131,7 +138,7 @@ /** Version string indicating version of this class (majorVersion*100+minorVersion * concatenated with a dot and the sorted date of last change. */ - static final public String version = "450.20140703"; + static final public String version = "451.20150909"; /** If terminate() was invoked, then this instance must not be used anymore. */ @@ -254,6 +261,93 @@ + /** Get the ooRexx <code>.local</code> directory. + * + * @return a <code>RexxProxy</code> allowing access to the ooRexx <code>.local</code> directory + * @since 2015-05-09 + */ + public Object getLocalEnvironment() + { +System.err.println(this+".getLocalEnvrionment(), before doing a \"return rexxInterface.jniGetLocalEnvironment(rii_ID);\" ..."); + if (rii_ID==null) // Rexx interpreter instance (RII) not yet created, create it! + { + throw new NullPointerException("\"rii_ID\" (Rexx interpereter instance ID) null, Rexx interpreter instance not yet created (just eval() or apply() a script))"); + } + + return rexxInterface.jniGetLocalEnvironment0(rii_ID); + } + + /** Get the ooRexx <code>.environment</code> directory. + * + * @return a <code>RexxProxy</code> allowing access to the ooRexx <code>.environment</code> directory + * @since 2015-05-09 + */ + public Object getGlobalEnvironment() + { + if (rii_ID==null) // Rexx interpreter instance (RII) not yet created, create it! + { + throw new NullPointerException("\"rii_ID\" (Rexx interpereter instance ID) null, Rexx interpreter instance not yet created (just eval() or apply() a script))"); + } + return rexxInterface.jniGetGlobalEnvironment0(rii_ID); + } + + /** Get the ooRexx <code>.nil</code> object. + * + * @return a <code>RexxProxy</code> representint the ooRexx <code>.nil</code> sentinel object + * @since 2015-05-09 + */ + public Object getNil() + { + if (rii_ID==null) // Rexx interpreter instance (RII) not yet created, create it! + { + throw new NullPointerException("\"rii_ID\" (Rexx interpereter instance ID) null, Rexx interpreter instance not yet created (just eval() or apply() a script))"); + } + return rexxInterface.jniNil0(rii_ID); + } + + + /** (Copied from the ooRexx <code>rexxpg.pdf</code> documentation) "Returns + * the version of the interpreter. The returned version is + * encoded in the 3 least significant bytes of the returned value, + * using 1 byte each for the interpreter version, release, and revision + * values. For example, on a 32-bit platform, this value would be + * <code>0x00040000</code> for version 4.0.0." + * + * @return the ooRexx interpreter version + * @since 2015-05-09 + */ + public long getInterpreterVersion() + { + if (rii_ID==null) // Rexx interpreter instance (RII) not yet created, create it! + { + throw new NullPointerException("\"rii_ID\" (Rexx interpereter instance ID) null, Rexx interpreter instance not yet created (just eval() or apply() a script))"); + } + return rexxInterface.jniInterpreterVersion0(rii_ID); + } + + + /** (Copied from the o... [truncated message content] |