While going over some homework of my students where they had to create a 
minimal JavaFX program, one
group came up with an example that offers a few interesting properties:

  * the nutshell is extremely short and consists of "main.rex", "button.fxml" 
and
    "button_handler.rex" (see enclosed)
  * an exception can sometimes (maybe once in ten attempts) occur, if the 
application "main.rex" is
    startet via rexx: "rexx main.rex"
      o this scenario causes Java to be demand loaded and then used via 
BSF4ooRexx
      o running the application brings up a little window with a button to be 
pressed (defined by
        "button.fxml");
          + press it
              # this will cause JavaFX to invoke the public routine 
"klickButtonActionscalc" in
                "button_handler.rex" which mereley creates an OLE-instance of 
the Internet Explorer,
                sets its dimension and navigates to www.google.at and returns 
thereafter
              # while the OLE-object gets created click the "x" system button 
to close the window
                with the button
                  * this click will be processed upon return from the 
"klickButtonActionscalc"
                    routine as that routine is run in the "JavaFX Application 
Thread" that manages
                    user input in GUIs and will block that thread until it 
returns and yields
      o *if* the exception occurs then always when the Rexx interpreter shuts 
down and runs an
        uninit in the orexxole.dll (!) library, cf. the enclosed 
"callStack-info.txt" file

This is the most minimal combination that I have seen so far, that creates the 
reported crash. If it
occurs, it does not occur in BSF4ooRexx but in pure ooRexx at termination time, 
so this may help in
debugging this. (I think it cannot get any simpler than this.)

---

This sample is also interesting, because I have not (!) managed to get that 
crash when running it
via Java using: "rexxj main.rex"! In this execution scenario Java is started 
and will load ooRexx
and then execute "main.rex" exactly the same way as above. The only difference 
is upon termination,
because Java issues the following warning: "Warning: orexxole.dll DLL process 
detach, instance count
(1) not 0". So this observation may also help debug the cause.

---

To successfully run this example one needs to temporarily install the latest 
BSF4ooRexx beta from
<https://sourceforge.net/projects/bsf4oorexx/files/beta/20161026/>, unzip the 
archive
<BSF4ooRexx_install_v600-20170713-beta.zip
<https://sourceforge.net/projects/bsf4oorexx/files/beta/20161026/BSF4ooRexx_install_v600-20170713-beta.zip/download>>,
change into "bsf4oorexx/install/windows" and double-click on "install.cmd". 
After installation, open
a new terminal, such that the new environment takes effect and run with "rexx 
main.rex" according to
the above directions. When done, uninstall BSF4ooRexx by using the Windows-menu 
entry "BSF4ooRexx ->
Installation -> Uninstall BSF4ooRexx". Installation and deinstallation take 
less than a minute! If
running 32-bit ooRexx (this is the version I tested) then you need to install 
the 32-bit version of
Java (both 32- and 64-bit Java can coexist).

---rony


rexxHandler=.rxDocHandler~new

rxApp=BsfCreateRexxProxy(rexxHandler,,"javafx.application.Application")

rxApp~launch(rxApp~getClass, .nil)

::requires "BSF.CLS"

::class RxDocHandler

::method start
use arg stage

stage~setTitle("INET")

rootDocUrl=.bsf~new("java.net.URL", "file:button.fxml")
root=bsf.loadClass("javafx.fxml.FXMLLoader")~load( rootDocUrl  )

scene=.bsf~new("javafx.scene.Scene", root)
stage~setScene(scene)
stage~show
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<?language rexx?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8.0.102"; xmlns:fx="http://javafx.com/fxml/1";>
<fx:script source="button_handler.rex" />

   <children>
<Button fx:id="franz" layoutX="125.0" layoutY="14.0" mnemonicParsing="false" prefHeight="60.0" prefWidth="200.0"
onAction=
                      "slotDir=arg(arg()) /* always supplied by BSF4ooRexx as the last argument */ ;
                       call klickButtonActionscalc slotDir /* now process the event, pass on slotDir */ ;"
text="Internet Explorer">
         <font>
            <Font name="System Bold" size="20.0" />
         </font>
      </Button>

   </children>
</AnchorPane>
::routine klickButtonActionscalc public
  use arg slotDir

arrived=.datetime~new
.stdout~say(arrived (arrived-arrived) "via stdout: arrived in 
klickButtonActionscalc()")

tmpDate1=.dateTime~new
.stdout~say(tmpDate1 (tmpDate1-arrived) "before .oleObject~new")
myIE = .OLEObject~New("InternetExplorer.Application")
tmpDate2=.dateTime~new
.stdout~say(tmpDate2 (tmpDate2-arrived) "AFTER .oleObject~new, duration:" 
(tmpDate2-tmpDate1) )

myIE~Width = 1024
myIE~Height = 768
myIE~Visible = .True

start=.dateTime~new
.stdout~say(start (start-arrived) "via stdout: about to navigate")
myIE~Navigate(" http://www.google.at ")
end=.dateTime~new
.stdout~say(end (end-arrived) "via stdout: done, about to return from 
klickButtonActionscalc")


Running "rexx main.rex", klicking the button and immediately the close-icon on 
the right upper-hand corner will cause a crash after a couple of attempts, all 
of this kind:

        ole32.dll!CAggId::~CAggId() Line 64     C++
        ole32.dll!CAggId::`scalar deleting destructor'(unsigned int)    C++
        ole32.dll!CAggId::Release() Line 251    C++
        ole32.dll!IUnknown_Release_Proxy(IUnknown * This=0x1934654c) Line 1773  
C++
>       orexxole.dll!OLEObject_Uninit_impl(RexxMethodContext_ * 
> context=0x0042d874, _RexxObjectPtr * self=0x7de957c0) Line 3136 C++
        orexxole.dll!OLEObject_Uninit(RexxMethodContext_ * context=0x0042d874, 
ValueDescriptor * arguments=0x0042d88c) Line 3075        C++
        rexx.dll!NativeActivation::run(MethodClass * _method=0x7ee74a6c, 
NativeMethod * _code=0x7ee753a4, RexxObject * _receiver=0x7de957c0, RexxString 
* _msgname=0x7ee66714, RexxObject * * _arglist=0x00000000, unsigned int 
_argcount=0, ProtectedObject & resultObj={...}) Line 1269       C++
        rexx.dll!NativeMethod::run(Activity * activity=0x7dba7a10, MethodClass 
* method=0x7ee74a6c, RexxObject * receiver=0x7de957c0, RexxString * 
messageName=0x7ee66714, RexxObject * * argPtr=0x00000000, unsigned int count=0, 
ProtectedObject & result={...}) Line 347     C++
        rexx.dll!MethodClass::run(Activity * activity=0x7dba7a10, RexxObject * 
receiver=0x7de957c0, RexxString * msgname=0x7ee66714, RexxObject * * 
argPtr=0x00000000, unsigned int count=0, ProtectedObject & result={...}) Line 
170   C++
        rexx.dll!RexxObject::messageSend(RexxString * msgname=0x7ee66714, 
RexxObject * * arguments=0x00000000, unsigned int count=0, ProtectedObject & 
result={...}) Line 839   C++
        rexx.dll!RexxObject::sendMessage(RexxString * message=0x7ee66714, 
ProtectedObject & result={...}) Line 486      C++
        rexx.dll!RexxObject::uninit() Line 2504 C++
        rexx.dll!UninitDispatcher::run() Line 54        C++
        rexx.dll!NativeActivation::run(TrappingDispatcher & dispatcher={...}) 
Line 1698 C++
        rexx.dll!Activity::run(TrappingDispatcher & target={...}) Line 3257     
C++
        rexx.dll!MemoryObject::runUninits() Line 363    C++
        rexx.dll!MemoryObject::collectAndUninit(bool clearStack=false) Line 305 
C++
        rexx.dll!InterpreterInstance::terminate() Line 498      C++
        rexx.dll!Terminate(RexxInstance_ * c=0x7dba4730) Line 58        C++
        rexx.exe!RexxInstance_::Terminate() Line 700    C++
        rexx.exe!main(int argc=2, char * * argv=0x004d81b0) Line 244    C++
        rexx.exe!invoke_main() Line 64  C++
        rexx.exe!__scrt_common_main_seh() Line 253      C++
        rexx.exe!__scrt_common_main() Line 296  C++
        rexx.exe!mainCRTStartup() Line 17       C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!___RtlUserThreadStart@8()    Unknown
        ntdll.dll!__RtlUserThreadStart@8()     Unknown


----

if invoked via Java using "rexxj main.rex" no crashes occur, but upon 
terminating the program the following warning is given by Java:

         "Warning: orexxole.dll DLL process detach, instance count (1) not 0"

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to