You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Geir Magnusson Jr." <ge...@pobox.com> on 2006/07/10 17:32:52 UTC

[drlvm] using the harmony launcher

What is required to get the DRLVM use the Harmony launcher ?

geir

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Tim Ellison <t....@gmail.com>.
Ivan Volosyuk wrote:
> Invocation API is missing in DRLVM. It should be implemented.
> Launcher should be updated:
>>>  char defaultDllName[] = "clearvm";

That should not be a blocker, as I mentioned before you can override it
on the command-line.

If you want to use a different name today:

  (1) In jre/bin/default rename clearvm.dll and clearvm.properties
      to <foo>.dll and <foo>.properties

  (2) Launch the VM with  java -vm:<foo> MyClass

I can pick a new name if you prefer.

> p.s. Invocation api is really good todo item. I'm looking forward to
> see browser plugin using DRLVM with classpath.

Browser plug-in requires much more than the invocation API.

Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Geir Magnusson Jr <ge...@pobox.com>.
Oliver Deakin wrote:
> Andrey Chernyshev wrote:
>>
>> (5)
>> What to do with the "_org.apache.harmony.vmi.portlib" option that
>> launcher is offering to VM?
> 
> This passes the classlib port library function table to the VM. I think
> this just makes the classlib port library available to the VM for it to
> use/query if it wishes. I think it is fine for the drlvm to ignore this
> option
> if it wants to.

When I see things like this, I get uncomfortable, because clearly
there's some big secret I'm not in on.

Why doesn't DRLVM give a hoot about the classlib port library?

Why is the VM subordinate to the classlibrary in this way?  Shouldn't
the VM supply the facility for this to the classlib?

Sincerely,
Confused in Connecticut

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Pavel Pervov <pm...@gmail.com>.
 Andrey,

<SNIP>


> The code for VMStart's init() and shutdown() is equally run regardless
> of whether drlvm is started with it's own or classlib launcher. The
> difference is only in running the user app main() method. Classlib
> launcher calls it directly, through JNI, while the drlvm's launcher
> wraps it into the run() method and always runs in a separate thread.
> I suspect there could be some difference in the classloader's used for
> the user app code, perhaps the drlvm classloading experts could give
> some more details.


Currently the application class is loaded by system class loader (class
loader returned by ClassLoader.getSystemClassLoader() call). Please, see
MainThread.run() in
vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java. The main
question here is what class loader classlib launcher will use to find main
application class. If it calls to jni->FindClass interface function then no
Java frame exists ontop of this call and, again, system class loader will be
user to load main application class. So, no difference actually exists.

<MORE SNIP>

>
> Yes, this sounds reasonable. Then, what should be the expected
> behavior for DestroyVM in case it finds pending exception, should it
> silently ignore it, or report a warning or what? JNI spec doesn't seem
> to specify these details.


AFAIK, JNI specification explicitly declares that no JNI function other than
ExceptionOccured, ExceptionCheck, and ExceptionDescribe are not guaranteed
to work in exception state. So, it is reasonable that the user of JNI
functions (classlib launcher in our case) clears exception (or process it
otherwise) before calling to any JNI function.

With the best regards,
    Pavel Pervov.
Intel Middleware Products Division.

Re: [drlvm] using the harmony launcher

Posted by Oliver Deakin <ol...@googlemail.com>.
Andrey Chernyshev wrote:
> On 7/17/06, Oliver Deakin <ol...@googlemail.com> wrote:
>> Andrey Chernyshev wrote:
>> <SNIP>
>> So, IMHO one of the first things that should be done after entering
>> DestroyJavaVM is to check for pending exceptions, and clear them
>> if they're going to interfere with the shutdown sequence.
>
> OK, I have added a simple check into the DestroyJavaVM method which
> does processing of the pending exceptions in HARMONY-927.

Great! Thanks,
Oliver

>
> Thanks,
> Andrey.
>
>
>>
>> I've just created a simple launcher that:
>>  - creates a Java VM
>>  - invokes the main method of a class that throws a RuntimeException
>>  - calls DestroyJavaVM without clearing the pending exception
>> Both the RI and IBM VMs exit without any complaints, so I think that
>> drlvm should match this behaviour also.
>>
>> Regards,
>> Oliver
>>
>> >
>> >>
>> >> >
>> >> > (3)
>> >> > CreateJavaVM can only be called once for now – many internal data
>> >> > structures in DRLVM are kept as global variables (jni_env, java_vm,
>> >> > Global_Env e.t.c.). Therefore, it will be hard to organize the
>> >> > multiple instances of JavaVM unless all these things are 
>> encapsulated
>> >> > somewhere (into JNIEnv?).
>> >> >
>> >> > (4)
>> >> > Launcher wants the vm dll in the "default" directory unless the 
>> option
>> >> > is specified. Should we realign the drlvm build output and move all
>> >> > dll's into the "default" subdir?
>> >>
>> >> yup, or put it into a deploy/jdk/jre/bin/drlvm directory and use the
>> >> launcher
>> >> options to specify its location.
>> >>
>> >> >
>> >> > (5)
>> >> > What to do with the "_org.apache.harmony.vmi.portlib" option that
>> >> > launcher is offering to VM?
>> >>
>> >> This passes the classlib port library function table to the VM. I 
>> think
>> >> this just makes the classlib port library available to the VM for 
>> it to
>> >> use/query if it wishes. I think it is fine for the drlvm to ignore 
>> this
>> >> option
>> >> if it wants to.
>> >>
>> >> Regards,
>> >> Oliver
>> >>
>> >> >
>> >> > Most likely there are more issues that I'm overlooking at the 
>> moment.
>> >> > Please consider the suggested patch is a workaround to make the 
>> things
>> >> > working, I'm wondering if there is a more graceful way to do this.
>> >> >
>> >> > Thanks,
>> >> > Andrey.
>> >> >
>> >> >
>> >> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> >> >> OK, so I'm going to add CreateJavaVM into 
>> vm\vmcore\src\jni\jni.cpp
>> >> >> and also add implementation into DestroyVM (stub is already seem
>> >> to be
>> >> >> present there) based on destroy_vm(). Then we'll see how it works
>> >> with
>> >> >> the launcher.
>> >> >>
>> >> >> Thanks,
>> >> >> Andrey.
>> >> >>
>> >> >>
>> >> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>> >> >> > This has been my thinking - even if not perfect, lets get it
>> >> working
>> >> >> > using the launcher and then fix as required. It's arguable if 
>> that
>> >> >> > "brokenness" matters at this point, and I think that there's
>> >> plenty to
>> >> >> > be gained from having it work via the launcher.
>> >> >> >
>> >> >> > geir
>> >> >> >
>> >> >> > Rana Dasgupta wrote:
>> >> >> > > create_vm() looks quite close/complete to being a complete
>> >> >> prototype for
>> >> >> > > CreateJavaVM,
>> >> >> > > but I think more work is needed in DestroyVM which prototypes
>> >> >> DestroyJavaVM
>> >> >> > > for functional completeness. It is non waiting on user 
>> threads,
>> >> >> it does not
>> >> >> > > send the corresponding JVMTI shutdown events, I also don't 
>> know
>> >> >> if it
>> >> >> > > handles shutdown hooks cleanly ( but these "may" not be 
>> critical
>> >> >> right now
>> >> >> > > for hooking up to the launcher ). What do you think?
>> >> >> > >
>> >> >> > > When I ran a non trivial test.. upto 32 threads 
>> instantiating a
>> >> >> very large
>> >> >> > > number of objects with -XcleanupOnExit which uses
>> >> >> DestroyVM, it
>> >> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
>> >> >> > >
>> >> >> > > Thanks,
>> >> >> > > Rana
>> >> >> > >
>> >> >> > >
>> >> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> 
>> wrote:
>> >> >> > >
>> >> >> > >> >Yes, it seems like the launcher will need at least
>> >> >> JNI_CreateJavaVM
>> >> >> > >> >and DestroyJavaVM functions.
>> >> >> > >>
>> >> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm
>> >> codebase.
>> >> >> > >> >Perhaps create_vm() function in 
>> vm\vmcore\src\init\vm_main.cpp
>> >> >> can be
>> >> >> > >> >adopted for that purpose?
>> >> >> > >> >Is there are any tricks and caveats one should be aware of
>> >> before
>> >> >> > >> >trying to produce CreateJavaVM from it?
>> >> >> > >>
>> >> >> > >> >I've also seen a prototype for DestroyJavaVM in
>> >> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be
>> >> >> improved to
>> >> >> > >> >wait till all Java threads are completed.
>> >> >> > >>
>> >> >> > >> >Any more ideas what needs to be done to implement those?
>> >> >> > >>
>> >> >> > >> >Thanks,
>> >> >> > >> >Andrey.
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> 
>> ---------------------------------------------------------------------
>> >> >> > >> Terms of use : 
>> http://incubator.apache.org/harmony/mailing.html
>> >> >> > >> To unsubscribe, e-mail:
>> >> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> > >> For additional commands, e-mail:
>> >> >> harmony-dev-help@incubator.apache.org
>> >> >> > >>
>> >> >> > >>
>> >> >> > >
>> >> >> >
>> >> >> >
>> >> ---------------------------------------------------------------------
>> >> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> >> > To unsubscribe, e-mail:
>> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> > For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Andrey Chernyshev
>> >> >> Intel Middleware Products Division
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> Oliver Deakin
>> >> IBM United Kingdom Limited
>> >>
>> >>
>> >
>> >
>>
>> -- 
>> Oliver Deakin
>> IBM United Kingdom Limited
>>
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
>
>

-- 
Oliver Deakin
IBM United Kingdom Limited


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
On 7/17/06, Oliver Deakin <ol...@googlemail.com> wrote:
> Andrey Chernyshev wrote:
> > On 7/13/06, Oliver Deakin <ol...@googlemail.com> wrote:
> >> Andrey Chernyshev wrote:
> >> <SNIP!>
> >>
> >>
> >> or:
> >> launcher calls CreateJavaVM()
> >> CreateJavaVM() passes call to create_vm()
> >> create_vm() makes its usual calls and returns. A flag is set to
> >> indicate that VMStart still needs to be run.
> >> create_vm() and CreateJavaVM() both exit, returning control to the
> >> launcher
> >> launcher makes a call to run some Java code (possibly main method)
> >> drlvm picks up flag indicating VMStart needs to be executed and runs
> >> it before the specified class
> >>
> >> The first approach seems better to me, since it gets all of the vm
> >> initialization
> >> completed within the CreateJavaVM() call.
> >
> > I also like the first approach, it would be strange behavior for JNI
> > CallXMethod to run the calls in a separate thread if some special flag
> > is found.
> >
> >
> >>
> >> Does this answer your question? Any other ideas?
> >
> > I don't think there is an issue with not running of certain parts of
> > VMStart: one can divide it into 3 different parts:
> > - initialization;
> > - running main() method of the user app (in a separate thread)
> > - shutdown.
> >
> > The code for VMStart's init() and shutdown() is equally run regardless
> > of whether drlvm is started with it's own or classlib launcher. The
> > difference is only in running the user app main() method. Classlib
> > launcher calls it directly, through JNI, while the drlvm's launcher
> > wraps it into the run() method and always runs in a separate thread.
> > I suspect there could be some difference in the classloader's used for
> > the user app code, perhaps the drlvm classloading experts could give
> > some more details.
>
> If we separate initialisation and execution of the main() method in VMStart
> so that CreateJavaVM works, is there actually a need to keep the
> main() method execution in there? I can't think of a reason to launch
> the main() method in a separate thread (perhaps, as you suggest, some
> drlvm experts can help with this one) - if there is no reason to do
> this, then I would probably suggest either altering the drlvm launcher
> to use a more conventional launcher approach (CreateJavaVM followed
> by CallStaticMethod) or abandoning the drlvm launcher in favour
> of the classlib one. Either way, I think the start() method in VMStart
> could probably be removed.
>
> >
> > Thanks,
> > Andrey.
> >
> >>
> >>
> >> >
> >> > (2)
> >> > If I pass a wrong app class name to the classlib launcher, drlvm
> >> > reports class not found exception and then is crashed. This happens
> >> > because the classlib launcher, once it fails to run the app class,
> >> > reports an exception (with ExceptionDescribe) but doesn't clear it
> >> > (doesn't call ExceptionClear). Then it immediately goes with
> >> > DestroyJavaVM those current implementation in drlvm doesn't expect
> >> > that there is some pending exception object in the TLS.
> >> > Eventually, destroy_vm fails with assert in the class loading code
> >> > while resolving VMStart class (VMStart holds the Java part of the
> >> > shutdown method), because it mistakenly picks up the ClassNotFound
> >> > exception object. It is remaining from unsuccessful attempt of
> >> > classlib launcher to run the app's class main method.
> >> >
> >> > The question is, who's responsibility should be to clear the exception
> >> > object in that case? I tend to think that classlib launcher should be
> >> > doing this once it takes the responsibility to process the possible
> >> > exceptions while running the app main class.
> >>
> >> Although the classlib launcher should probably tidy up after itself and
> >> call ExceptionClear, I don't believe that there is a spec requirement to
> >> clear pending exceptions before calling DestroyJavaVM. Therefore
> >> any launcher could call DestroyJavaVM with an exception pending,
> >> and drlvm would throw a ClassNotFound.
> >> IMHO drlvm should handle the fact that an exception already exists
> >> on entering DestroyJavaVM, and clear it before trying to resolve
> >> the VMStart class.
> >
> > Yes, this sounds reasonable. Then, what should be the expected
> > behavior for DestroyVM in case it finds pending exception, should it
> > silently ignore it, or report a warning or what? JNI spec doesn't seem
> > to specify these details.
>
> Agreed, the JNI spec isn't too clear on this matter.
> In JNI, handling of uncaught exceptions is expected to be done
> by the developer (ie using ExceptionOccurred, ExceptionDescribe,
> ExceptionClear) rather than the VM. This leads me to think that if
> any exceptions have not been cleared by the JNI code before
> DestroyJavaVM() is called, then the developer will expect the VM
> to just silently ignore them and carry on shutting down.
>
> So, IMHO one of the first things that should be done after entering
> DestroyJavaVM is to check for pending exceptions, and clear them
> if they're going to interfere with the shutdown sequence.

OK, I have added a simple check into the DestroyJavaVM method which
does processing of the pending exceptions in HARMONY-927.

Thanks,
Andrey.


>
> I've just created a simple launcher that:
>  - creates a Java VM
>  - invokes the main method of a class that throws a RuntimeException
>  - calls DestroyJavaVM without clearing the pending exception
> Both the RI and IBM VMs exit without any complaints, so I think that
> drlvm should match this behaviour also.
>
> Regards,
> Oliver
>
> >
> >>
> >> >
> >> > (3)
> >> > CreateJavaVM can only be called once for now – many internal data
> >> > structures in DRLVM are kept as global variables (jni_env, java_vm,
> >> > Global_Env e.t.c.). Therefore, it will be hard to organize the
> >> > multiple instances of JavaVM unless all these things are encapsulated
> >> > somewhere (into JNIEnv?).
> >> >
> >> > (4)
> >> > Launcher wants the vm dll in the "default" directory unless the option
> >> > is specified. Should we realign the drlvm build output and move all
> >> > dll's into the "default" subdir?
> >>
> >> yup, or put it into a deploy/jdk/jre/bin/drlvm directory and use the
> >> launcher
> >> options to specify its location.
> >>
> >> >
> >> > (5)
> >> > What to do with the "_org.apache.harmony.vmi.portlib" option that
> >> > launcher is offering to VM?
> >>
> >> This passes the classlib port library function table to the VM. I think
> >> this just makes the classlib port library available to the VM for it to
> >> use/query if it wishes. I think it is fine for the drlvm to ignore this
> >> option
> >> if it wants to.
> >>
> >> Regards,
> >> Oliver
> >>
> >> >
> >> > Most likely there are more issues that I'm overlooking at the moment.
> >> > Please consider the suggested patch is a workaround to make the things
> >> > working, I'm wondering if there is a more graceful way to do this.
> >> >
> >> > Thanks,
> >> > Andrey.
> >> >
> >> >
> >> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> >> OK, so I'm going to add CreateJavaVM into vm\vmcore\src\jni\jni.cpp
> >> >> and also add implementation into DestroyVM (stub is already seem
> >> to be
> >> >> present there) based on destroy_vm(). Then we'll see how it works
> >> with
> >> >> the launcher.
> >> >>
> >> >> Thanks,
> >> >> Andrey.
> >> >>
> >> >>
> >> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> >> >> > This has been my thinking - even if not perfect, lets get it
> >> working
> >> >> > using the launcher and then fix as required. It's arguable if that
> >> >> > "brokenness" matters at this point, and I think that there's
> >> plenty to
> >> >> > be gained from having it work via the launcher.
> >> >> >
> >> >> > geir
> >> >> >
> >> >> > Rana Dasgupta wrote:
> >> >> > > create_vm() looks quite close/complete to being a complete
> >> >> prototype for
> >> >> > > CreateJavaVM,
> >> >> > > but I think more work is needed in DestroyVM which prototypes
> >> >> DestroyJavaVM
> >> >> > > for functional completeness. It is non waiting on user threads,
> >> >> it does not
> >> >> > > send the corresponding JVMTI shutdown events, I also don't know
> >> >> if it
> >> >> > > handles shutdown hooks cleanly ( but these "may" not be critical
> >> >> right now
> >> >> > > for hooking up to the launcher ). What do you think?
> >> >> > >
> >> >> > > When I ran a non trivial test.. upto 32 threads instantiating a
> >> >> very large
> >> >> > > number of objects with -XcleanupOnExit which uses
> >> >> DestroyVM, it
> >> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> >> >> > >
> >> >> > > Thanks,
> >> >> > > Rana
> >> >> > >
> >> >> > >
> >> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> >> > >
> >> >> > >> >Yes, it seems like the launcher will need at least
> >> >> JNI_CreateJavaVM
> >> >> > >> >and DestroyJavaVM functions.
> >> >> > >>
> >> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm
> >> codebase.
> >> >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
> >> >> can be
> >> >> > >> >adopted for that purpose?
> >> >> > >> >Is there are any tricks and caveats one should be aware of
> >> before
> >> >> > >> >trying to produce CreateJavaVM from it?
> >> >> > >>
> >> >> > >> >I've also seen a prototype for DestroyJavaVM in
> >> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be
> >> >> improved to
> >> >> > >> >wait till all Java threads are completed.
> >> >> > >>
> >> >> > >> >Any more ideas what needs to be done to implement those?
> >> >> > >>
> >> >> > >> >Thanks,
> >> >> > >> >Andrey.
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> ---------------------------------------------------------------------
> >> >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> > >> To unsubscribe, e-mail:
> >> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> > >> For additional commands, e-mail:
> >> >> harmony-dev-help@incubator.apache.org
> >> >> > >>
> >> >> > >>
> >> >> > >
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> > To unsubscribe, e-mail:
> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> > For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >> --
> >> >> Andrey Chernyshev
> >> >> Intel Middleware Products Division
> >> >>
> >> >
> >> >
> >>
> >> --
> >> Oliver Deakin
> >> IBM United Kingdom Limited
> >>
> >>
> >
> >
>
> --
> Oliver Deakin
> IBM United Kingdom Limited
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Oliver Deakin <ol...@googlemail.com>.
Andrey Chernyshev wrote:
> On 7/13/06, Oliver Deakin <ol...@googlemail.com> wrote:
>> Andrey Chernyshev wrote:
>> <SNIP!>
>>
>>
>> or:
>> launcher calls CreateJavaVM()
>> CreateJavaVM() passes call to create_vm()
>> create_vm() makes its usual calls and returns. A flag is set to
>> indicate that VMStart still needs to be run.
>> create_vm() and CreateJavaVM() both exit, returning control to the
>> launcher
>> launcher makes a call to run some Java code (possibly main method)
>> drlvm picks up flag indicating VMStart needs to be executed and runs
>> it before the specified class
>>
>> The first approach seems better to me, since it gets all of the vm
>> initialization
>> completed within the CreateJavaVM() call.
>
> I also like the first approach, it would be strange behavior for JNI
> CallXMethod to run the calls in a separate thread if some special flag
> is found.
>
>
>>
>> Does this answer your question? Any other ideas?
>
> I don't think there is an issue with not running of certain parts of
> VMStart: one can divide it into 3 different parts:
> - initialization;
> - running main() method of the user app (in a separate thread)
> - shutdown.
>
> The code for VMStart's init() and shutdown() is equally run regardless
> of whether drlvm is started with it's own or classlib launcher. The
> difference is only in running the user app main() method. Classlib
> launcher calls it directly, through JNI, while the drlvm's launcher
> wraps it into the run() method and always runs in a separate thread.
> I suspect there could be some difference in the classloader's used for
> the user app code, perhaps the drlvm classloading experts could give
> some more details.

If we separate initialisation and execution of the main() method in VMStart
so that CreateJavaVM works, is there actually a need to keep the
main() method execution in there? I can't think of a reason to launch
the main() method in a separate thread (perhaps, as you suggest, some
drlvm experts can help with this one) - if there is no reason to do
this, then I would probably suggest either altering the drlvm launcher
to use a more conventional launcher approach (CreateJavaVM followed
by CallStaticMethod) or abandoning the drlvm launcher in favour
of the classlib one. Either way, I think the start() method in VMStart
could probably be removed.

>
> Thanks,
> Andrey.
>
>>
>>
>> >
>> > (2)
>> > If I pass a wrong app class name to the classlib launcher, drlvm
>> > reports class not found exception and then is crashed. This happens
>> > because the classlib launcher, once it fails to run the app class,
>> > reports an exception (with ExceptionDescribe) but doesn't clear it
>> > (doesn't call ExceptionClear). Then it immediately goes with
>> > DestroyJavaVM those current implementation in drlvm doesn't expect
>> > that there is some pending exception object in the TLS.
>> > Eventually, destroy_vm fails with assert in the class loading code
>> > while resolving VMStart class (VMStart holds the Java part of the
>> > shutdown method), because it mistakenly picks up the ClassNotFound
>> > exception object. It is remaining from unsuccessful attempt of
>> > classlib launcher to run the app's class main method.
>> >
>> > The question is, who's responsibility should be to clear the exception
>> > object in that case? I tend to think that classlib launcher should be
>> > doing this once it takes the responsibility to process the possible
>> > exceptions while running the app main class.
>>
>> Although the classlib launcher should probably tidy up after itself and
>> call ExceptionClear, I don't believe that there is a spec requirement to
>> clear pending exceptions before calling DestroyJavaVM. Therefore
>> any launcher could call DestroyJavaVM with an exception pending,
>> and drlvm would throw a ClassNotFound.
>> IMHO drlvm should handle the fact that an exception already exists
>> on entering DestroyJavaVM, and clear it before trying to resolve
>> the VMStart class.
>
> Yes, this sounds reasonable. Then, what should be the expected
> behavior for DestroyVM in case it finds pending exception, should it
> silently ignore it, or report a warning or what? JNI spec doesn't seem
> to specify these details.

Agreed, the JNI spec isn't too clear on this matter.
In JNI, handling of uncaught exceptions is expected to be done
by the developer (ie using ExceptionOccurred, ExceptionDescribe,
ExceptionClear) rather than the VM. This leads me to think that if
any exceptions have not been cleared by the JNI code before
DestroyJavaVM() is called, then the developer will expect the VM
to just silently ignore them and carry on shutting down.

So, IMHO one of the first things that should be done after entering
DestroyJavaVM is to check for pending exceptions, and clear them
if they're going to interfere with the shutdown sequence.

I've just created a simple launcher that:
  - creates a Java VM
  - invokes the main method of a class that throws a RuntimeException
  - calls DestroyJavaVM without clearing the pending exception
Both the RI and IBM VMs exit without any complaints, so I think that
drlvm should match this behaviour also.

Regards,
Oliver

>
>>
>> >
>> > (3)
>> > CreateJavaVM can only be called once for now – many internal data
>> > structures in DRLVM are kept as global variables (jni_env, java_vm,
>> > Global_Env e.t.c.). Therefore, it will be hard to organize the
>> > multiple instances of JavaVM unless all these things are encapsulated
>> > somewhere (into JNIEnv?).
>> >
>> > (4)
>> > Launcher wants the vm dll in the "default" directory unless the option
>> > is specified. Should we realign the drlvm build output and move all
>> > dll's into the "default" subdir?
>>
>> yup, or put it into a deploy/jdk/jre/bin/drlvm directory and use the
>> launcher
>> options to specify its location.
>>
>> >
>> > (5)
>> > What to do with the "_org.apache.harmony.vmi.portlib" option that
>> > launcher is offering to VM?
>>
>> This passes the classlib port library function table to the VM. I think
>> this just makes the classlib port library available to the VM for it to
>> use/query if it wishes. I think it is fine for the drlvm to ignore this
>> option
>> if it wants to.
>>
>> Regards,
>> Oliver
>>
>> >
>> > Most likely there are more issues that I'm overlooking at the moment.
>> > Please consider the suggested patch is a workaround to make the things
>> > working, I'm wondering if there is a more graceful way to do this.
>> >
>> > Thanks,
>> > Andrey.
>> >
>> >
>> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> >> OK, so I'm going to add CreateJavaVM into vm\vmcore\src\jni\jni.cpp
>> >> and also add implementation into DestroyVM (stub is already seem 
>> to be
>> >> present there) based on destroy_vm(). Then we'll see how it works 
>> with
>> >> the launcher.
>> >>
>> >> Thanks,
>> >> Andrey.
>> >>
>> >>
>> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>> >> > This has been my thinking - even if not perfect, lets get it 
>> working
>> >> > using the launcher and then fix as required. It's arguable if that
>> >> > "brokenness" matters at this point, and I think that there's 
>> plenty to
>> >> > be gained from having it work via the launcher.
>> >> >
>> >> > geir
>> >> >
>> >> > Rana Dasgupta wrote:
>> >> > > create_vm() looks quite close/complete to being a complete
>> >> prototype for
>> >> > > CreateJavaVM,
>> >> > > but I think more work is needed in DestroyVM which prototypes
>> >> DestroyJavaVM
>> >> > > for functional completeness. It is non waiting on user threads,
>> >> it does not
>> >> > > send the corresponding JVMTI shutdown events, I also don't know
>> >> if it
>> >> > > handles shutdown hooks cleanly ( but these "may" not be critical
>> >> right now
>> >> > > for hooking up to the launcher ). What do you think?
>> >> > >
>> >> > > When I ran a non trivial test.. upto 32 threads instantiating a
>> >> very large
>> >> > > number of objects with -XcleanupOnExit which uses
>> >> DestroyVM, it
>> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
>> >> > >
>> >> > > Thanks,
>> >> > > Rana
>> >> > >
>> >> > >
>> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> >> > >
>> >> > >> >Yes, it seems like the launcher will need at least
>> >> JNI_CreateJavaVM
>> >> > >> >and DestroyJavaVM functions.
>> >> > >>
>> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm 
>> codebase.
>> >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
>> >> can be
>> >> > >> >adopted for that purpose?
>> >> > >> >Is there are any tricks and caveats one should be aware of 
>> before
>> >> > >> >trying to produce CreateJavaVM from it?
>> >> > >>
>> >> > >> >I've also seen a prototype for DestroyJavaVM in
>> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be
>> >> improved to
>> >> > >> >wait till all Java threads are completed.
>> >> > >>
>> >> > >> >Any more ideas what needs to be done to implement those?
>> >> > >>
>> >> > >> >Thanks,
>> >> > >> >Andrey.
>> >> > >>
>> >> > >>
>> >> > >>
>> >> ---------------------------------------------------------------------
>> >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > >> To unsubscribe, e-mail:
>> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> > >> For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> > >>
>> >> > >>
>> >> > >
>> >> >
>> >> > 
>> ---------------------------------------------------------------------
>> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > To unsubscribe, e-mail: 
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> > For additional commands, e-mail: 
>> harmony-dev-help@incubator.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >> Andrey Chernyshev
>> >> Intel Middleware Products Division
>> >>
>> >
>> >
>>
>> -- 
>> Oliver Deakin
>> IBM United Kingdom Limited
>>
>>
>
>

-- 
Oliver Deakin
IBM United Kingdom Limited


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
On 7/13/06, Oliver Deakin <ol...@googlemail.com> wrote:
> Andrey Chernyshev wrote:
> > With some changes I was able to run the DRLVM with classlib's
> > launcher. Here is what I did (you can see the experimental patch at
> > http://issues.apache.org/jira/browse/HARMONY-857):
> >
> > - I have added JNI_CreateJavaVM declaration to jni.h (guess it will be
> > the most appropriate place for it);
> >
> > - Added a simple implementations for JNI_CreateJavaVM and
> > DestroyJavaVM based on the existing create_vm and detroy_vm functions
> > in the vmcore/init submodule.
> >
> > - To make vmcore/init functions visible for vmcore/jni code, I have
> > moved vmcore/init/init.h to vmcore/include;
> >
> > - In parse_arguments.cpp, I had to silently ignore the option
> > "_org.apache.harmony.vmi.portlib" which is passed by the launcher to
> > VM for some reason, causing the DRLVM to complain about "unknown
> > option". What is the purpose of that option, should I process it
> > differently?
> >
> >
> > After all, I was able to run the DRLVM under classlib's launcher on
> > Windows with a command like:
> >
> > Java.exe -vm:vmcore -vmdir:. Hello
> >
> > and even was able to run Eclipse IDE with it. VM seems to exit cleanly
> > and didn't report any error messages.
>
> Good work!
>
> >
> > Some of the remaining issues / observations are:
> >
> > (1)
> > DRLVM startup is organized a bit differently compared to the classlib
> > launcher startup, namely – the DRLVM after creating VM runs a special
> > class called VMStart which is, in it's turn, asynchronously calling
> > the main() method of the user application in a separate thread.
> > When we go with the classlib's launcher, the main() method is executed
> > in the same thread where the JavaVM is created.
> > What are the caveats with that?
>
> I've had a look in the drlvm code, and I see what you mean - run_java_main
> is expecting to receive the class name as a parameter, then launch the
> VMStart class before running main().
>
> It is standard practice for a Java launcher to call CreateJavaVM(),
> then carry out a findClass() and CallStaticObjectMethod() on the specified
> class and main method. However, the launcher does not necessarily have to
> run the main method first - anyone could write a custom launcher that
> calls a static "runme()" method first, or something similar, so the VM
> should
> not expect main() to be the first method called when launched from the
> invocation API.
>
> So, if I understand the drlvm code right, the call sequence on startup using
> the drlvm launcher is:
>
> drlvm launcher calls vm_main()
> vm_main() calls create_vm() (which is essentially CreateJavaVM)
> create_vm() completes and returns
> vm_main() calls run_main()
> run_main() calls run_java_main()
> run_java_main() creates the VMStart class and executes its start() method
> run_java_main() creates the specified class and runs its main() method
>

Yes, this description of the drlvm startup sequence looks correct, I
was observing the same.

> When drlvm is launched using a generic launcher (such as the classlib
> launcher) the sequence would probably need to be either:
>
> launcher calls CreateJavaVM()
> CreateJavaVM() passes call to create_vm()
> create_vm() makes its usual calls, but also executes required VMStart
> code
> create_vm() and CreateJavaVM() both exit, returning control to the
> launcher
>
> or:
> launcher calls CreateJavaVM()
> CreateJavaVM() passes call to create_vm()
> create_vm() makes its usual calls and returns. A flag is set to
> indicate that VMStart still needs to be run.
> create_vm() and CreateJavaVM() both exit, returning control to the
> launcher
> launcher makes a call to run some Java code (possibly main method)
> drlvm picks up flag indicating VMStart needs to be executed and runs
> it before the specified class
>
> The first approach seems better to me, since it gets all of the vm
> initialization
> completed within the CreateJavaVM() call.

I also like the first approach, it would be strange behavior for JNI
CallXMethod to run the calls in a separate thread if some special flag
is found.


>
> Does this answer your question? Any other ideas?

I don't think there is an issue with not running of certain parts of
VMStart: one can divide it into 3 different parts:
- initialization;
- running main() method of the user app (in a separate thread)
- shutdown.

The code for VMStart's init() and shutdown() is equally run regardless
of whether drlvm is started with it's own or classlib launcher. The
difference is only in running the user app main() method. Classlib
launcher calls it directly, through JNI, while the drlvm's launcher
wraps it into the run() method and always runs in a separate thread.
I suspect there could be some difference in the classloader's used for
the user app code, perhaps the drlvm classloading experts could give
some more details.

Thanks,
Andrey.

>
>
> >
> > (2)
> > If I pass a wrong app class name to the classlib launcher, drlvm
> > reports class not found exception and then is crashed. This happens
> > because the classlib launcher, once it fails to run the app class,
> > reports an exception (with ExceptionDescribe) but doesn't clear it
> > (doesn't call ExceptionClear). Then it immediately goes with
> > DestroyJavaVM those current implementation in drlvm doesn't expect
> > that there is some pending exception object in the TLS.
> > Eventually, destroy_vm fails with assert in the class loading code
> > while resolving VMStart class (VMStart holds the Java part of the
> > shutdown method), because it mistakenly picks up the ClassNotFound
> > exception object. It is remaining from unsuccessful attempt of
> > classlib launcher to run the app's class main method.
> >
> > The question is, who's responsibility should be to clear the exception
> > object in that case? I tend to think that classlib launcher should be
> > doing this once it takes the responsibility to process the possible
> > exceptions while running the app main class.
>
> Although the classlib launcher should probably tidy up after itself and
> call ExceptionClear, I don't believe that there is a spec requirement to
> clear pending exceptions before calling DestroyJavaVM. Therefore
> any launcher could call DestroyJavaVM with an exception pending,
> and drlvm would throw a ClassNotFound.
> IMHO drlvm should handle the fact that an exception already exists
> on entering DestroyJavaVM, and clear it before trying to resolve
> the VMStart class.

Yes, this sounds reasonable. Then, what should be the expected
behavior for DestroyVM in case it finds pending exception, should it
silently ignore it, or report a warning or what? JNI spec doesn't seem
to specify these details.

>
> >
> > (3)
> > CreateJavaVM can only be called once for now – many internal data
> > structures in DRLVM are kept as global variables (jni_env, java_vm,
> > Global_Env e.t.c.). Therefore, it will be hard to organize the
> > multiple instances of JavaVM unless all these things are encapsulated
> > somewhere (into JNIEnv?).
> >
> > (4)
> > Launcher wants the vm dll in the "default" directory unless the option
> > is specified. Should we realign the drlvm build output and move all
> > dll's into the "default" subdir?
>
> yup, or put it into a deploy/jdk/jre/bin/drlvm directory and use the
> launcher
> options to specify its location.
>
> >
> > (5)
> > What to do with the "_org.apache.harmony.vmi.portlib" option that
> > launcher is offering to VM?
>
> This passes the classlib port library function table to the VM. I think
> this just makes the classlib port library available to the VM for it to
> use/query if it wishes. I think it is fine for the drlvm to ignore this
> option
> if it wants to.
>
> Regards,
> Oliver
>
> >
> > Most likely there are more issues that I'm overlooking at the moment.
> > Please consider the suggested patch is a workaround to make the things
> > working, I'm wondering if there is a more graceful way to do this.
> >
> > Thanks,
> > Andrey.
> >
> >
> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> OK, so I'm going to add CreateJavaVM into vm\vmcore\src\jni\jni.cpp
> >> and also add implementation into DestroyVM (stub is already seem to be
> >> present there) based on destroy_vm(). Then we'll see how it works with
> >> the launcher.
> >>
> >> Thanks,
> >> Andrey.
> >>
> >>
> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> >> > This has been my thinking - even if not perfect, lets get it working
> >> > using the launcher and then fix as required. It's arguable if that
> >> > "brokenness" matters at this point, and I think that there's plenty to
> >> > be gained from having it work via the launcher.
> >> >
> >> > geir
> >> >
> >> > Rana Dasgupta wrote:
> >> > > create_vm() looks quite close/complete to being a complete
> >> prototype for
> >> > > CreateJavaVM,
> >> > > but I think more work is needed in DestroyVM which prototypes
> >> DestroyJavaVM
> >> > > for functional completeness. It is non waiting on user threads,
> >> it does not
> >> > > send the corresponding JVMTI shutdown events, I also don't know
> >> if it
> >> > > handles shutdown hooks cleanly ( but these "may" not be critical
> >> right now
> >> > > for hooking up to the launcher ). What do you think?
> >> > >
> >> > > When I ran a non trivial test.. upto 32 threads instantiating a
> >> very large
> >> > > number of objects with -XcleanupOnExit which uses
> >> DestroyVM, it
> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> >> > >
> >> > > Thanks,
> >> > > Rana
> >> > >
> >> > >
> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> > >
> >> > >> >Yes, it seems like the launcher will need at least
> >> JNI_CreateJavaVM
> >> > >> >and DestroyJavaVM functions.
> >> > >>
> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
> >> can be
> >> > >> >adopted for that purpose?
> >> > >> >Is there are any tricks and caveats one should be aware of before
> >> > >> >trying to produce CreateJavaVM from it?
> >> > >>
> >> > >> >I've also seen a prototype for DestroyJavaVM in
> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be
> >> improved to
> >> > >> >wait till all Java threads are completed.
> >> > >>
> >> > >> >Any more ideas what needs to be done to implement those?
> >> > >>
> >> > >> >Thanks,
> >> > >> >Andrey.
> >> > >>
> >> > >>
> >> > >>
> >> ---------------------------------------------------------------------
> >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> > >> To unsubscribe, e-mail:
> >> harmony-dev-unsubscribe@incubator.apache.org
> >> > >> For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> > >>
> >> > >>
> >> > >
> >> >
> >> > ---------------------------------------------------------------------
> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> Andrey Chernyshev
> >> Intel Middleware Products Division
> >>
> >
> >
>
> --
> Oliver Deakin
> IBM United Kingdom Limited
>
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Oliver Deakin <ol...@googlemail.com>.
Andrey Chernyshev wrote:
> With some changes I was able to run the DRLVM with classlib's
> launcher. Here is what I did (you can see the experimental patch at
> http://issues.apache.org/jira/browse/HARMONY-857):
>
> - I have added JNI_CreateJavaVM declaration to jni.h (guess it will be
> the most appropriate place for it);
>
> - Added a simple implementations for JNI_CreateJavaVM and
> DestroyJavaVM based on the existing create_vm and detroy_vm functions
> in the vmcore/init submodule.
>
> - To make vmcore/init functions visible for vmcore/jni code, I have
> moved vmcore/init/init.h to vmcore/include;
>
> - In parse_arguments.cpp, I had to silently ignore the option
> "_org.apache.harmony.vmi.portlib" which is passed by the launcher to
> VM for some reason, causing the DRLVM to complain about "unknown
> option". What is the purpose of that option, should I process it
> differently?
>
>
> After all, I was able to run the DRLVM under classlib's launcher on
> Windows with a command like:
>
> Java.exe -vm:vmcore -vmdir:. Hello
>
> and even was able to run Eclipse IDE with it. VM seems to exit cleanly
> and didn't report any error messages.

Good work!

>
> Some of the remaining issues / observations are:
>
> (1)
> DRLVM startup is organized a bit differently compared to the classlib
> launcher startup, namely – the DRLVM after creating VM runs a special
> class called VMStart which is, in it's turn, asynchronously calling
> the main() method of the user application in a separate thread.
> When we go with the classlib's launcher, the main() method is executed
> in the same thread where the JavaVM is created.
> What are the caveats with that?

I've had a look in the drlvm code, and I see what you mean - run_java_main
is expecting to receive the class name as a parameter, then launch the
VMStart class before running main().

It is standard practice for a Java launcher to call CreateJavaVM(),
then carry out a findClass() and CallStaticObjectMethod() on the specified
class and main method. However, the launcher does not necessarily have to
run the main method first - anyone could write a custom launcher that
calls a static "runme()" method first, or something similar, so the VM
should
not expect main() to be the first method called when launched from the
invocation API.

So, if I understand the drlvm code right, the call sequence on startup using
the drlvm launcher is:

drlvm launcher calls vm_main()
vm_main() calls create_vm() (which is essentially CreateJavaVM)
create_vm() completes and returns
vm_main() calls run_main()
run_main() calls run_java_main()
run_java_main() creates the VMStart class and executes its start() method
run_java_main() creates the specified class and runs its main() method

When drlvm is launched using a generic launcher (such as the classlib
launcher) the sequence would probably need to be either:

launcher calls CreateJavaVM()
CreateJavaVM() passes call to create_vm()
create_vm() makes its usual calls, but also executes required VMStart
code
create_vm() and CreateJavaVM() both exit, returning control to the
launcher

or:
launcher calls CreateJavaVM()
CreateJavaVM() passes call to create_vm()
create_vm() makes its usual calls and returns. A flag is set to
indicate that VMStart still needs to be run.
create_vm() and CreateJavaVM() both exit, returning control to the
launcher
launcher makes a call to run some Java code (possibly main method)
drlvm picks up flag indicating VMStart needs to be executed and runs
it before the specified class

The first approach seems better to me, since it gets all of the vm
initialization
completed within the CreateJavaVM() call.

Does this answer your question? Any other ideas?


>
> (2)
> If I pass a wrong app class name to the classlib launcher, drlvm
> reports class not found exception and then is crashed. This happens
> because the classlib launcher, once it fails to run the app class,
> reports an exception (with ExceptionDescribe) but doesn't clear it
> (doesn't call ExceptionClear). Then it immediately goes with
> DestroyJavaVM those current implementation in drlvm doesn't expect
> that there is some pending exception object in the TLS.
> Eventually, destroy_vm fails with assert in the class loading code
> while resolving VMStart class (VMStart holds the Java part of the
> shutdown method), because it mistakenly picks up the ClassNotFound
> exception object. It is remaining from unsuccessful attempt of
> classlib launcher to run the app's class main method.
>
> The question is, who's responsibility should be to clear the exception
> object in that case? I tend to think that classlib launcher should be
> doing this once it takes the responsibility to process the possible
> exceptions while running the app main class.

Although the classlib launcher should probably tidy up after itself and
call ExceptionClear, I don't believe that there is a spec requirement to
clear pending exceptions before calling DestroyJavaVM. Therefore
any launcher could call DestroyJavaVM with an exception pending,
and drlvm would throw a ClassNotFound.
IMHO drlvm should handle the fact that an exception already exists
on entering DestroyJavaVM, and clear it before trying to resolve
the VMStart class.

>
> (3)
> CreateJavaVM can only be called once for now – many internal data
> structures in DRLVM are kept as global variables (jni_env, java_vm,
> Global_Env e.t.c.). Therefore, it will be hard to organize the
> multiple instances of JavaVM unless all these things are encapsulated
> somewhere (into JNIEnv?).
>
> (4)
> Launcher wants the vm dll in the "default" directory unless the option
> is specified. Should we realign the drlvm build output and move all
> dll's into the "default" subdir?

yup, or put it into a deploy/jdk/jre/bin/drlvm directory and use the
launcher
options to specify its location.

>
> (5)
> What to do with the "_org.apache.harmony.vmi.portlib" option that
> launcher is offering to VM?

This passes the classlib port library function table to the VM. I think
this just makes the classlib port library available to the VM for it to
use/query if it wishes. I think it is fine for the drlvm to ignore this
option
if it wants to.

Regards,
Oliver

>
> Most likely there are more issues that I'm overlooking at the moment.
> Please consider the suggested patch is a workaround to make the things
> working, I'm wondering if there is a more graceful way to do this.
>
> Thanks,
> Andrey.
>
>
> On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> OK, so I'm going to add CreateJavaVM into vm\vmcore\src\jni\jni.cpp
>> and also add implementation into DestroyVM (stub is already seem to be
>> present there) based on destroy_vm(). Then we'll see how it works with
>> the launcher.
>>
>> Thanks,
>> Andrey.
>>
>>
>> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>> > This has been my thinking - even if not perfect, lets get it working
>> > using the launcher and then fix as required. It's arguable if that
>> > "brokenness" matters at this point, and I think that there's plenty to
>> > be gained from having it work via the launcher.
>> >
>> > geir
>> >
>> > Rana Dasgupta wrote:
>> > > create_vm() looks quite close/complete to being a complete
>> prototype for
>> > > CreateJavaVM,
>> > > but I think more work is needed in DestroyVM which prototypes
>> DestroyJavaVM
>> > > for functional completeness. It is non waiting on user threads,
>> it does not
>> > > send the corresponding JVMTI shutdown events, I also don't know
>> if it
>> > > handles shutdown hooks cleanly ( but these "may" not be critical
>> right now
>> > > for hooking up to the launcher ). What do you think?
>> > >
>> > > When I ran a non trivial test.. upto 32 threads instantiating a
>> very large
>> > > number of objects with -XcleanupOnExit which uses
>> DestroyVM, it
>> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
>> > >
>> > > Thanks,
>> > > Rana
>> > >
>> > >
>> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> > >
>> > >> >Yes, it seems like the launcher will need at least
>> JNI_CreateJavaVM
>> > >> >and DestroyJavaVM functions.
>> > >>
>> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
>> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
>> can be
>> > >> >adopted for that purpose?
>> > >> >Is there are any tricks and caveats one should be aware of before
>> > >> >trying to produce CreateJavaVM from it?
>> > >>
>> > >> >I've also seen a prototype for DestroyJavaVM in
>> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be
>> improved to
>> > >> >wait till all Java threads are completed.
>> > >>
>> > >> >Any more ideas what needs to be done to implement those?
>> > >>
>> > >> >Thanks,
>> > >> >Andrey.
>> > >>
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > >> To unsubscribe, e-mail:
>> harmony-dev-unsubscribe@incubator.apache.org
>> > >> For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> > >>
>> > >>
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>>
>> --
>> Andrey Chernyshev
>> Intel Middleware Products Division
>>
>
>

-- 
Oliver Deakin
IBM United Kingdom Limited

Re: [drlvm] using the harmony launcher

Posted by Geir Magnusson Jr <ge...@pobox.com>.
Andrey Chernyshev wrote:
> With some changes I was able to run the DRLVM with classlib's
> launcher. Here is what I did (you can see the experimental patch at
> http://issues.apache.org/jira/browse/HARMONY-857):

This is very cool.  Why experimental?  what is the big problem if we
accept it and go on from there?

[SNIP]

> 
> (1)
> DRLVM startup is organized a bit differently compared to the classlib
> launcher startup, namely – the DRLVM after creating VM runs a special
> class called VMStart which is, in it's turn, asynchronously calling
> the main() method of the user application in a separate thread.
> When we go with the classlib's launcher, the main() method is executed
> in the same thread where the JavaVM is created.
> What are the caveats with that?

And why is that?

[SNIP]


> (4)
> Launcher wants the vm dll in the "default" directory unless the option
> is specified. Should we realign the drlvm build output and move all
> dll's into the "default" subdir?

I think so.

> 
> (5)
> What to do with the "_org.apache.harmony.vmi.portlib" option that
> launcher is offering to VM?
> 
> Most likely there are more issues that I'm overlooking at the moment.
> Please consider the suggested patch is a workaround to make the things
> working, I'm wondering if there is a more graceful way to do this.

It's better that what we have, and we can just build on from here...

geir

> 
> Thanks,
> Andrey.
> 
> 
> On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
>> and also add implementation into DestroyVM (stub is already seem to be
>> present there) based on destroy_vm(). Then we'll see how it works with
>> the launcher.
>>
>> Thanks,
>> Andrey.
>>
>>
>> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>> > This has been my thinking - even if not perfect, lets get it working
>> > using the launcher and then fix as required.  It's arguable if that
>> > "brokenness" matters at this point, and I think that there's plenty to
>> > be gained from having it work via the launcher.
>> >
>> > geir
>> >
>> > Rana Dasgupta wrote:
>> > > create_vm() looks quite close/complete to being a complete
>> prototype for
>> > > CreateJavaVM,
>> > > but I think more work is needed in DestroyVM which prototypes
>> DestroyJavaVM
>> > > for functional completeness. It is non waiting on user threads, it
>> does not
>> > > send the corresponding JVMTI shutdown events, I also don't know if it
>> > > handles shutdown hooks cleanly ( but these "may" not be critical
>> right now
>> > > for hooking up to the launcher ). What do you think?
>> > >
>> > > When I ran a non trivial test.. upto 32 threads instantiating a
>> very large
>> > > number of objects  with            -XcleanupOnExit which uses
>> DestroyVM, it
>> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
>> > >
>> > > Thanks,
>> > > Rana
>> > >
>> > >
>> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> > >
>> > >> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
>> > >> >and DestroyJavaVM functions.
>> > >>
>> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
>> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
>> can be
>> > >> >adopted for that purpose?
>> > >> >Is there are any tricks and caveats one should be aware of before
>> > >> >trying to produce CreateJavaVM from it?
>> > >>
>> > >> >I've also seen a prototype for DestroyJavaVM in
>> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
>> > >> >wait till all Java threads are completed.
>> > >>
>> > >> >Any more ideas what needs to be done to implement those?
>> > >>
>> > >> >Thanks,
>> > >> >Andrey.
>> > >>
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > >> For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> > >>
>> > >>
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>>
>> -- 
>> Andrey Chernyshev
>> Intel Middleware Products Division
>>
> 
> 

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Tim Ellison <t....@gmail.com>.
Andrey Chernyshev wrote:
> Thanks Oliver, this does clarify a lot. I'll see if I could change
> drlvm's vmi impl such that it transfers the original portlib pointer
> obtained from the launcher.

That would be great, thanks Andrey.

> BTW: are we expecting to have the multiple instances of the port
> library? Can't it be a singleton those instance is simply obtained via
> GetPortLibrary() function exported in hyprt.dll or whatever? I'm
> wondering if we really need to pass the pointer throughout the
> different parts of a the system.

It is passed along so that any application that creates a Java VM
instance can specify the port library that it wants the class library to
use.  While today Harmony is only using JNI_CreateJavaVM in the
launcher, that is not the only expected usage.

For the same reason, the class library code should not be using statric
variables in the native code.  The VMI provides for VM-local storage so
that multiple instances of the VM in a single process running through
the classlib code do not trample on each other's static area.

Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
On 7/17/06, Oliver Deakin <ol...@googlemail.com> wrote:
> Andrey Chernyshev wrote:
> > On 7/13/06, Tim Ellison <t....@gmail.com> wrote:
> >> Andrey Chernyshev wrote:
> >> <snip>
> >>
> >>
> >> > (4)
> >> > Launcher wants the vm dll in the "default" directory unless the option
> >> > is specified. Should we realign the drlvm build output and move all
> >> > dll's into the "default" subdir?
> >>
> >> I'll let the different Harmony VM folk argue about who should be the
> >> default ;-)  I agree that it should no longer be the IBM VME.
> >>
> >> > (5)
> >> > What to do with the "_org.apache.harmony.vmi.portlib" option that
> >> > launcher is offering to VM?
> >>
> >> So the laucher creates the portlib function table so it can do OS things
> >> (like write NLS messages, and open the VM DLLs etc), it then passes the
> >> portlib in to the VM as this argument.
> >
> > How the string "_org.apache.harmony.vmi.portlib" which is passed to VM
> > as an argument maps to a function table created by launcher? On VM
> > side, I guess I'm getting only that string from the launcher about the
> > portlib, nothing else...
>
> The _org.apache.harmony.vmi.portlib option is passed to the VM
> as a JavaVMOption struct (defined in jni.h) that looks like:
>
> typedef struct JavaVMOption
> {
>   char *optionString;
>   void *extraInfo;
> } JavaVMOption;
>
> When the launcher passes the _org.apache.harmony.vmi.portlib option
> to the VM it sets optionString to be "_org.apache.harmony.vmi.portlib"
> and extraInfo to be the pointer to the port library. We can see this in
> modules/luni/src/main/native/launcher/shared/main.c:
>
>   options[j].optionString = portLibOptionStr;
>   options[j].extraInfo = portLibrary;
>
> So, on the VM side, once you find the JavaVMOption that has
> optionString=="_org.apache.harmony.vmi.portlib", then its extraInfo
> field will contain the relevant port library pointer.
>
>
> >
> >>
> >> You can choose to ignore it, but since you are required to return a
> >> portlib from the VMI's GetPortLibrary call, you might as well just
> >> remember it.
> >>
> >> It would be more polite to remember the one you were given so that the
> >> caller can install their own portlib functions and have them back again
> >> onthe VMI calls.
> >
> > So it sounds like the launcher creates portlib, passes it to VM and
> > then expects it to be returned back from VM. What's the purpose of
> > doing that?
>
> Kind of... Remember that the launcher isn't technically part of the
> class library native code (it really should be completely separate
> from classlib - what happened to the plan to move it out of classlib?).
> So what actually happens is that the launcher creates a port library
> and passes it to the VM. The VM stores this portlib pointer away
> somewhere for future use.
> One of the VMI functions provided by the VM is GetPortLibrary()
> (the VMInterfaceFunctions struct is declared in
> modules/luni/src/main/native/include/shared/vmi.h). So when the
> Harmony classlib natives call this function they expect to receive
> a pointer to an HyPortLibrary from the VM- since the VM has
> already been given one by the launcher, it can just return that one.
>
> > Shall we consider the portlib as a part of classlib or VM? If the
> > classlib is responsible for instantiation of the portlib,  then why
> > the classlib should be expecting to get it once again from VM? I'm
> > sure there must be some tricks there which I'm not getting yet...
>
> I hope that what Ive described above might clarify things slightly -
> that the portlib is created by the launcher, which isn't really part
> of the classlib, then passed to the VM to be given to the classlib
> upon request in the future.

Thanks Oliver, this does clarify a lot. I'll see if I could change
drlvm's vmi impl such that it transfers the original portlib pointer
obtained from the launcher.
BTW: are we expecting to have the multiple instances of the port
library? Can't it be a singleton those instance is simply obtained via
GetPortLibrary() function exported in hyprt.dll or whatever? I'm
wondering if we really need to pass the pointer throughout the
different parts of a the system.

Thanks,
Andrey.


>
> Regards,
> Oliver
>
> >
> > Thanks,
> > Andrey.
> >
> >>
> >> > Most likely there are more issues that I'm overlooking at the moment.
> >> > Please consider the suggested patch is a workaround to make the things
> >> > working, I'm wondering if there is a more graceful way to do this.
> >>
> >> Good work Andrey, keep sending the questions and patches!
> >>
> >> Regards,
> >> Tim
> >>
> >>
> >> > Thanks,
> >> > Andrey.
> >> >
> >> >
> >> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> >> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
> >> >> and also add implementation into DestroyVM (stub is already seem
> >> to be
> >> >> present there) based on destroy_vm(). Then we'll see how it works
> >> with
> >> >> the launcher.
> >> >>
> >> >> Thanks,
> >> >> Andrey.
> >> >>
> >> >>
> >> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> >> >> > This has been my thinking - even if not perfect, lets get it
> >> working
> >> >> > using the launcher and then fix as required.  It's arguable if that
> >> >> > "brokenness" matters at this point, and I think that there's
> >> plenty to
> >> >> > be gained from having it work via the launcher.
> >> >> >
> >> >> > geir
> >> >> >
> >> >> > Rana Dasgupta wrote:
> >> >> > > create_vm() looks quite close/complete to being a complete
> >> >> prototype for
> >> >> > > CreateJavaVM,
> >> >> > > but I think more work is needed in DestroyVM which prototypes
> >> >> DestroyJavaVM
> >> >> > > for functional completeness. It is non waiting on user
> >> threads, it
> >> >> does not
> >> >> > > send the corresponding JVMTI shutdown events, I also don't
> >> know if it
> >> >> > > handles shutdown hooks cleanly ( but these "may" not be critical
> >> >> right now
> >> >> > > for hooking up to the launcher ). What do you think?
> >> >> > >
> >> >> > > When I ran a non trivial test.. upto 32 threads instantiating a
> >> >> very large
> >> >> > > number of objects  with            -XcleanupOnExit which uses
> >> >> DestroyVM, it
> >> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> >> >> > >
> >> >> > > Thanks,
> >> >> > > Rana
> >> >> > >
> >> >> > >
> >> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> >> > >
> >> >> > >> >Yes, it seems like the launcher will need at least
> >> JNI_CreateJavaVM
> >> >> > >> >and DestroyJavaVM functions.
> >> >> > >>
> >> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm
> >> codebase.
> >> >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
> >> >> can be
> >> >> > >> >adopted for that purpose?
> >> >> > >> >Is there are any tricks and caveats one should be aware of
> >> before
> >> >> > >> >trying to produce CreateJavaVM from it?
> >> >> > >>
> >> >> > >> >I've also seen a prototype for DestroyJavaVM in
> >> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be
> >> improved to
> >> >> > >> >wait till all Java threads are completed.
> >> >> > >>
> >> >> > >> >Any more ideas what needs to be done to implement those?
> >> >> > >>
> >> >> > >> >Thanks,
> >> >> > >> >Andrey.
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> ---------------------------------------------------------------------
> >> >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> > >> To unsubscribe, e-mail:
> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> > >> For additional commands, e-mail:
> >> >> harmony-dev-help@incubator.apache.org
> >> >> > >>
> >> >> > >>
> >> >> > >
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> > To unsubscribe, e-mail:
> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> > For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >> --
> >> >> Andrey Chernyshev
> >> >> Intel Middleware Products Division
> >> >>
> >> >
> >> >
> >>
> >> --
> >>
> >> Tim Ellison (t.p.ellison@gmail.com)
> >> IBM Java technology centre, UK.
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
> >
>
> --
> Oliver Deakin
> IBM United Kingdom Limited
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Oliver Deakin <ol...@googlemail.com>.
Andrey Chernyshev wrote:
> On 7/13/06, Tim Ellison <t....@gmail.com> wrote:
>> Andrey Chernyshev wrote:
>> <snip>
>>
>>
>> > (4)
>> > Launcher wants the vm dll in the "default" directory unless the option
>> > is specified. Should we realign the drlvm build output and move all
>> > dll's into the "default" subdir?
>>
>> I'll let the different Harmony VM folk argue about who should be the
>> default ;-)  I agree that it should no longer be the IBM VME.
>>
>> > (5)
>> > What to do with the "_org.apache.harmony.vmi.portlib" option that
>> > launcher is offering to VM?
>>
>> So the laucher creates the portlib function table so it can do OS things
>> (like write NLS messages, and open the VM DLLs etc), it then passes the
>> portlib in to the VM as this argument.
>
> How the string "_org.apache.harmony.vmi.portlib" which is passed to VM
> as an argument maps to a function table created by launcher? On VM
> side, I guess I'm getting only that string from the launcher about the
> portlib, nothing else...

The _org.apache.harmony.vmi.portlib option is passed to the VM
as a JavaVMOption struct (defined in jni.h) that looks like:

typedef struct JavaVMOption
{
   char *optionString;
   void *extraInfo;
} JavaVMOption;

When the launcher passes the _org.apache.harmony.vmi.portlib option
to the VM it sets optionString to be "_org.apache.harmony.vmi.portlib"
and extraInfo to be the pointer to the port library. We can see this in
modules/luni/src/main/native/launcher/shared/main.c:

   options[j].optionString = portLibOptionStr;
   options[j].extraInfo = portLibrary;

So, on the VM side, once you find the JavaVMOption that has
optionString=="_org.apache.harmony.vmi.portlib", then its extraInfo
field will contain the relevant port library pointer.


>
>>
>> You can choose to ignore it, but since you are required to return a
>> portlib from the VMI's GetPortLibrary call, you might as well just
>> remember it.
>>
>> It would be more polite to remember the one you were given so that the
>> caller can install their own portlib functions and have them back again
>> onthe VMI calls.
>
> So it sounds like the launcher creates portlib, passes it to VM and
> then expects it to be returned back from VM. What's the purpose of
> doing that?

Kind of... Remember that the launcher isn't technically part of the
class library native code (it really should be completely separate
from classlib - what happened to the plan to move it out of classlib?).
So what actually happens is that the launcher creates a port library
and passes it to the VM. The VM stores this portlib pointer away
somewhere for future use.
One of the VMI functions provided by the VM is GetPortLibrary()
(the VMInterfaceFunctions struct is declared in
modules/luni/src/main/native/include/shared/vmi.h). So when the
Harmony classlib natives call this function they expect to receive
a pointer to an HyPortLibrary from the VM- since the VM has
already been given one by the launcher, it can just return that one.

> Shall we consider the portlib as a part of classlib or VM? If the
> classlib is responsible for instantiation of the portlib,  then why
> the classlib should be expecting to get it once again from VM? I'm
> sure there must be some tricks there which I'm not getting yet...

I hope that what Ive described above might clarify things slightly -
that the portlib is created by the launcher, which isn't really part
of the classlib, then passed to the VM to be given to the classlib
upon request in the future.

Regards,
Oliver

>
> Thanks,
> Andrey.
>
>>
>> > Most likely there are more issues that I'm overlooking at the moment.
>> > Please consider the suggested patch is a workaround to make the things
>> > working, I'm wondering if there is a more graceful way to do this.
>>
>> Good work Andrey, keep sending the questions and patches!
>>
>> Regards,
>> Tim
>>
>>
>> > Thanks,
>> > Andrey.
>> >
>> >
>> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> >> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
>> >> and also add implementation into DestroyVM (stub is already seem 
>> to be
>> >> present there) based on destroy_vm(). Then we'll see how it works 
>> with
>> >> the launcher.
>> >>
>> >> Thanks,
>> >> Andrey.
>> >>
>> >>
>> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>> >> > This has been my thinking - even if not perfect, lets get it 
>> working
>> >> > using the launcher and then fix as required.  It's arguable if that
>> >> > "brokenness" matters at this point, and I think that there's 
>> plenty to
>> >> > be gained from having it work via the launcher.
>> >> >
>> >> > geir
>> >> >
>> >> > Rana Dasgupta wrote:
>> >> > > create_vm() looks quite close/complete to being a complete
>> >> prototype for
>> >> > > CreateJavaVM,
>> >> > > but I think more work is needed in DestroyVM which prototypes
>> >> DestroyJavaVM
>> >> > > for functional completeness. It is non waiting on user 
>> threads, it
>> >> does not
>> >> > > send the corresponding JVMTI shutdown events, I also don't 
>> know if it
>> >> > > handles shutdown hooks cleanly ( but these "may" not be critical
>> >> right now
>> >> > > for hooking up to the launcher ). What do you think?
>> >> > >
>> >> > > When I ran a non trivial test.. upto 32 threads instantiating a
>> >> very large
>> >> > > number of objects  with            -XcleanupOnExit which uses
>> >> DestroyVM, it
>> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
>> >> > >
>> >> > > Thanks,
>> >> > > Rana
>> >> > >
>> >> > >
>> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> >> > >
>> >> > >> >Yes, it seems like the launcher will need at least 
>> JNI_CreateJavaVM
>> >> > >> >and DestroyJavaVM functions.
>> >> > >>
>> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm 
>> codebase.
>> >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
>> >> can be
>> >> > >> >adopted for that purpose?
>> >> > >> >Is there are any tricks and caveats one should be aware of 
>> before
>> >> > >> >trying to produce CreateJavaVM from it?
>> >> > >>
>> >> > >> >I've also seen a prototype for DestroyJavaVM in
>> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be 
>> improved to
>> >> > >> >wait till all Java threads are completed.
>> >> > >>
>> >> > >> >Any more ideas what needs to be done to implement those?
>> >> > >>
>> >> > >> >Thanks,
>> >> > >> >Andrey.
>> >> > >>
>> >> > >>
>> >> > >>
>> >> ---------------------------------------------------------------------
>> >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > >> To unsubscribe, e-mail: 
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> > >> For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> > >>
>> >> > >>
>> >> > >
>> >> >
>> >> > 
>> ---------------------------------------------------------------------
>> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > To unsubscribe, e-mail: 
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> > For additional commands, e-mail: 
>> harmony-dev-help@incubator.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >> Andrey Chernyshev
>> >> Intel Middleware Products Division
>> >>
>> >
>> >
>>
>> -- 
>>
>> Tim Ellison (t.p.ellison@gmail.com)
>> IBM Java technology centre, UK.
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
>
>

-- 
Oliver Deakin
IBM United Kingdom Limited


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Alexey Varlamov <al...@gmail.com>.
2006/7/15, Andrey Chernyshev <a....@gmail.com>:
> On 7/13/06, Tim Ellison <t....@gmail.com> wrote:
> > Andrey Chernyshev wrote:
> > > With some changes I was able to run the DRLVM with classlib's
> > > launcher. Here is what I did (you can see the experimental patch at
> > > http://issues.apache.org/jira/browse/HARMONY-857):
> > >
> > > - I have added JNI_CreateJavaVM declaration to jni.h (guess it will be
> > > the most appropriate place for it);
> >
> > The existing jni.h in the HDK's jdk/include directory already has those
> > definitions.  The JNI function definitions are, of course, required by
> > the class library / tooling code.  We should probably just share one
> > copy of that file.
> >
> > > - Added a simple implementations for JNI_CreateJavaVM and
> > > DestroyJavaVM based on the existing create_vm and detroy_vm functions
> > > in the vmcore/init submodule.
> > >
> > > - To make vmcore/init functions visible for vmcore/jni code, I have
> > > moved vmcore/init/init.h to vmcore/include;
> > >
> > > - In parse_arguments.cpp, I had to silently ignore the option
> > > "_org.apache.harmony.vmi.portlib" which is passed by the launcher to
> > > VM for some reason, causing the DRLVM to complain about "unknown
> > > option".  What is the purpose of that option, should I process it
> > > differently?
> >
> > (see below)
> >
> > > After all, I was able to run the DRLVM under classlib's launcher on
> > > Windows with a command like:
> > >
> > > Java.exe -vm:vmcore -vmdir:. Hello
> >
> > Cool, they should be -X options, I'll change it in the launcher when
> > next in there.
> >
> > > and even was able to run Eclipse IDE with it. VM seems to exit cleanly
> > > and didn't report any error messages.
> > >
> > > Some of the remaining issues / observations are:
> > >
> > > (1)
> > > DRLVM startup is organized a bit differently compared to the classlib
> > > launcher startup, namely – the DRLVM after creating VM runs a special
> > > class called VMStart which is, in it's turn, asynchronously calling
> > > the main() method of the user application in a separate thread.
> >
> > That's an interesting design choice.  So it always runs the
> > VMStart#start() method as soon as the VM is created?  So how do you
> > implement JNI_CreateJavaVM (which must not do that)?
>
> With the classlib launcher,  JNI_CreateJavaVM calls only initialize()
> method from VMStrart right now. The VMStart.start() is never called,
> so the main() method of the user app is invoked directly by the
> launcher. I do think this is the right way to start applications, at
> least this is what JNI spec suggests.
> However, I'd like to understand if we can just replace the current
> main() invocation scheme via VMstrat#start() in drlvm with a direct
> call to main() from the classlib launcher, or we actually need to do
> something more special about that.

If I grok it right, the current design with VMStart.start() was aimed
for 2 points:
1) Unify the way Java threads are created/attached. That is, the main
app thread only executes VM internal tasks (initialization &
shutdown), and delegates actual work to newly spawned Java threads.
2) Simplify or provide cleaner shutdown sequence. The main thread just
hooks up for Java thread termination events and checks if a died
thread was the last non-daemon one, then triggers shutdown process.

So, if my guess is correct, to depart from this schema painlessly we
need to ensure that correct provisions are taken for attaching the
main thread and move VMStart.shutdown() functionality to
DestroyJavaVM.

--
Alexey Varlamov
> >
> > Our tools etc. will have custom launchers that run different classes in
> > the o.a.h.tools package.
> >
> > > When we go with the classlib's launcher, the main() method is executed
> > > in the same thread where the JavaVM is created.
> > > What are the caveats with that?
> >
> > Don't know, as you say the primordial thread does the JNI_CreateJavaVM
> > then goes on to CallStaticVoidMethod on the target's main().
> >
> > > (2)
> > > If I pass a wrong app class name to the classlib launcher, drlvm
> > > reports class not found exception and then is crashed. This happens
> > > because the classlib launcher, once it fails to run the app class,
> > > reports an exception (with ExceptionDescribe) but doesn't clear it
> > > (doesn't call ExceptionClear). Then it immediately goes with
> > > DestroyJavaVM those current implementation in drlvm doesn't expect
> > > that there is some pending exception object in the TLS.
> >
> > We can fix this in the launcher if you want, but cannot promise that
> > everyone else using the invocation API will do this for you.
> >
> > > Eventually, destroy_vm fails with assert in the class loading code
> > > while resolving VMStart class (VMStart holds the Java part of the
> > > shutdown method), because it mistakenly picks up the ClassNotFound
> > > exception object. It is remaining from unsuccessful attempt of
> > > classlib launcher to run the app's class main method.
> > >
> > > The question is, who's responsibility should be to clear the exception
> > > object in that case? I tend to think that classlib launcher should be
> > > doing this once it takes the responsibility to process the possible
> > > exceptions while running the app main class.
> >
> > Ok, but I'd advise that the Destroy is made more robust too.
>
> I agree with that.
>
> >
> > > (3)
> > > CreateJavaVM can only be called once for now – many internal data
> > > structures in DRLVM are kept as global variables (jni_env, java_vm,
> > > Global_Env e.t.c.).  Therefore, it will be hard to organize the
> > > multiple instances of JavaVM unless all these things are encapsulated
> > > somewhere (into JNIEnv?).
> >
> > Too bad.
> >
> > > (4)
> > > Launcher wants the vm dll in the "default" directory unless the option
> > > is specified. Should we realign the drlvm build output and move all
> > > dll's into the "default" subdir?
> >
> > I'll let the different Harmony VM folk argue about who should be the
> > default ;-)  I agree that it should no longer be the IBM VME.
> >
> > > (5)
> > > What to do with the "_org.apache.harmony.vmi.portlib" option that
> > > launcher is offering to VM?
> >
> > So the laucher creates the portlib function table so it can do OS things
> > (like write NLS messages, and open the VM DLLs etc), it then passes the
> > portlib in to the VM as this argument.
>
> How the string "_org.apache.harmony.vmi.portlib" which is passed to VM
> as an argument maps to a function table created by launcher? On VM
> side, I guess I'm getting only that string from the launcher about the
> portlib, nothing else...
>
> >
> > You can choose to ignore it, but since you are required to return a
> > portlib from the VMI's GetPortLibrary call, you might as well just
> > remember it.
> >
> > It would be more polite to remember the one you were given so that the
> > caller can install their own portlib functions and have them back again
> > onthe VMI calls.
>
> So it sounds like the launcher creates portlib, passes it to VM and
> then expects it to be returned back from VM. What's the purpose of
> doing that?
> Shall we consider the portlib as a part of classlib or VM? If the
> classlib is responsible for instantiation of the portlib,  then why
> the classlib should be expecting to get it once again from VM? I'm
> sure there must be some tricks there which I'm not getting yet...
>
> Thanks,
> Andrey.
>
> >
> > > Most likely there are more issues that I'm overlooking at the moment.
> > > Please consider the suggested patch is a workaround to make the things
> > > working, I'm wondering if there is a more graceful way to do this.
> >
> > Good work Andrey, keep sending the questions and patches!
> >
> > Regards,
> > Tim
> >
> >
> > > Thanks,
> > > Andrey.
> > >
> > >
> > > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
> > >> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
> > >> and also add implementation into DestroyVM (stub is already seem to be
> > >> present there) based on destroy_vm(). Then we'll see how it works with
> > >> the launcher.
> > >>
> > >> Thanks,
> > >> Andrey.
> > >>
> > >>
> > >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> > >> > This has been my thinking - even if not perfect, lets get it working
> > >> > using the launcher and then fix as required.  It's arguable if that
> > >> > "brokenness" matters at this point, and I think that there's plenty to
> > >> > be gained from having it work via the launcher.
> > >> >
> > >> > geir
> > >> >
> > >> > Rana Dasgupta wrote:
> > >> > > create_vm() looks quite close/complete to being a complete
> > >> prototype for
> > >> > > CreateJavaVM,
> > >> > > but I think more work is needed in DestroyVM which prototypes
> > >> DestroyJavaVM
> > >> > > for functional completeness. It is non waiting on user threads, it
> > >> does not
> > >> > > send the corresponding JVMTI shutdown events, I also don't know if it
> > >> > > handles shutdown hooks cleanly ( but these "may" not be critical
> > >> right now
> > >> > > for hooking up to the launcher ). What do you think?
> > >> > >
> > >> > > When I ran a non trivial test.. upto 32 threads instantiating a
> > >> very large
> > >> > > number of objects  with            -XcleanupOnExit which uses
> > >> DestroyVM, it
> > >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> > >> > >
> > >> > > Thanks,
> > >> > > Rana
> > >> > >
> > >> > >
> > >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> > >> > >
> > >> > >> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
> > >> > >> >and DestroyJavaVM functions.
> > >> > >>
> > >> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> > >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
> > >> can be
> > >> > >> >adopted for that purpose?
> > >> > >> >Is there are any tricks and caveats one should be aware of before
> > >> > >> >trying to produce CreateJavaVM from it?
> > >> > >>
> > >> > >> >I've also seen a prototype for DestroyJavaVM in
> > >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
> > >> > >> >wait till all Java threads are completed.
> > >> > >>
> > >> > >> >Any more ideas what needs to be done to implement those?
> > >> > >>
> > >> > >> >Thanks,
> > >> > >> >Andrey.
> > >> > >>
> > >> > >>
> > >> > >>
> > >> ---------------------------------------------------------------------
> > >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> > >> > >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > >> > >> For additional commands, e-mail:
> > >> harmony-dev-help@incubator.apache.org
> > >> > >>
> > >> > >>
> > >> > >
> > >> >
> > >> > ---------------------------------------------------------------------
> > >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > >> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >> >
> > >> >
> > >>
> > >>
> > >> --
> > >> Andrey Chernyshev
> > >> Intel Middleware Products Division
> > >>
> > >
> > >
> >
> > --
> >
> > Tim Ellison (t.p.ellison@gmail.com)
> > IBM Java technology centre, UK.
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Andrey Chernyshev
> Intel Middleware Products Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
On 7/13/06, Tim Ellison <t....@gmail.com> wrote:
> Andrey Chernyshev wrote:
> > With some changes I was able to run the DRLVM with classlib's
> > launcher. Here is what I did (you can see the experimental patch at
> > http://issues.apache.org/jira/browse/HARMONY-857):
> >
> > - I have added JNI_CreateJavaVM declaration to jni.h (guess it will be
> > the most appropriate place for it);
>
> The existing jni.h in the HDK's jdk/include directory already has those
> definitions.  The JNI function definitions are, of course, required by
> the class library / tooling code.  We should probably just share one
> copy of that file.
>
> > - Added a simple implementations for JNI_CreateJavaVM and
> > DestroyJavaVM based on the existing create_vm and detroy_vm functions
> > in the vmcore/init submodule.
> >
> > - To make vmcore/init functions visible for vmcore/jni code, I have
> > moved vmcore/init/init.h to vmcore/include;
> >
> > - In parse_arguments.cpp, I had to silently ignore the option
> > "_org.apache.harmony.vmi.portlib" which is passed by the launcher to
> > VM for some reason, causing the DRLVM to complain about "unknown
> > option".  What is the purpose of that option, should I process it
> > differently?
>
> (see below)
>
> > After all, I was able to run the DRLVM under classlib's launcher on
> > Windows with a command like:
> >
> > Java.exe -vm:vmcore -vmdir:. Hello
>
> Cool, they should be -X options, I'll change it in the launcher when
> next in there.
>
> > and even was able to run Eclipse IDE with it. VM seems to exit cleanly
> > and didn't report any error messages.
> >
> > Some of the remaining issues / observations are:
> >
> > (1)
> > DRLVM startup is organized a bit differently compared to the classlib
> > launcher startup, namely – the DRLVM after creating VM runs a special
> > class called VMStart which is, in it's turn, asynchronously calling
> > the main() method of the user application in a separate thread.
>
> That's an interesting design choice.  So it always runs the
> VMStart#start() method as soon as the VM is created?  So how do you
> implement JNI_CreateJavaVM (which must not do that)?

With the classlib launcher,  JNI_CreateJavaVM calls only initialize()
method from VMStrart right now. The VMStart.start() is never called,
so the main() method of the user app is invoked directly by the
launcher. I do think this is the right way to start applications, at
least this is what JNI spec suggests.
However, I'd like to understand if we can just replace the current
main() invocation scheme via VMstrat#start() in drlvm with a direct
call to main() from the classlib launcher, or we actually need to do
something more special about that.

>
> Our tools etc. will have custom launchers that run different classes in
> the o.a.h.tools package.
>
> > When we go with the classlib's launcher, the main() method is executed
> > in the same thread where the JavaVM is created.
> > What are the caveats with that?
>
> Don't know, as you say the primordial thread does the JNI_CreateJavaVM
> then goes on to CallStaticVoidMethod on the target's main().
>
> > (2)
> > If I pass a wrong app class name to the classlib launcher, drlvm
> > reports class not found exception and then is crashed. This happens
> > because the classlib launcher, once it fails to run the app class,
> > reports an exception (with ExceptionDescribe) but doesn't clear it
> > (doesn't call ExceptionClear). Then it immediately goes with
> > DestroyJavaVM those current implementation in drlvm doesn't expect
> > that there is some pending exception object in the TLS.
>
> We can fix this in the launcher if you want, but cannot promise that
> everyone else using the invocation API will do this for you.
>
> > Eventually, destroy_vm fails with assert in the class loading code
> > while resolving VMStart class (VMStart holds the Java part of the
> > shutdown method), because it mistakenly picks up the ClassNotFound
> > exception object. It is remaining from unsuccessful attempt of
> > classlib launcher to run the app's class main method.
> >
> > The question is, who's responsibility should be to clear the exception
> > object in that case? I tend to think that classlib launcher should be
> > doing this once it takes the responsibility to process the possible
> > exceptions while running the app main class.
>
> Ok, but I'd advise that the Destroy is made more robust too.

I agree with that.

>
> > (3)
> > CreateJavaVM can only be called once for now – many internal data
> > structures in DRLVM are kept as global variables (jni_env, java_vm,
> > Global_Env e.t.c.).  Therefore, it will be hard to organize the
> > multiple instances of JavaVM unless all these things are encapsulated
> > somewhere (into JNIEnv?).
>
> Too bad.
>
> > (4)
> > Launcher wants the vm dll in the "default" directory unless the option
> > is specified. Should we realign the drlvm build output and move all
> > dll's into the "default" subdir?
>
> I'll let the different Harmony VM folk argue about who should be the
> default ;-)  I agree that it should no longer be the IBM VME.
>
> > (5)
> > What to do with the "_org.apache.harmony.vmi.portlib" option that
> > launcher is offering to VM?
>
> So the laucher creates the portlib function table so it can do OS things
> (like write NLS messages, and open the VM DLLs etc), it then passes the
> portlib in to the VM as this argument.

How the string "_org.apache.harmony.vmi.portlib" which is passed to VM
as an argument maps to a function table created by launcher? On VM
side, I guess I'm getting only that string from the launcher about the
portlib, nothing else...

>
> You can choose to ignore it, but since you are required to return a
> portlib from the VMI's GetPortLibrary call, you might as well just
> remember it.
>
> It would be more polite to remember the one you were given so that the
> caller can install their own portlib functions and have them back again
> onthe VMI calls.

So it sounds like the launcher creates portlib, passes it to VM and
then expects it to be returned back from VM. What's the purpose of
doing that?
Shall we consider the portlib as a part of classlib or VM? If the
classlib is responsible for instantiation of the portlib,  then why
the classlib should be expecting to get it once again from VM? I'm
sure there must be some tricks there which I'm not getting yet...

Thanks,
Andrey.

>
> > Most likely there are more issues that I'm overlooking at the moment.
> > Please consider the suggested patch is a workaround to make the things
> > working, I'm wondering if there is a more graceful way to do this.
>
> Good work Andrey, keep sending the questions and patches!
>
> Regards,
> Tim
>
>
> > Thanks,
> > Andrey.
> >
> >
> > On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
> >> and also add implementation into DestroyVM (stub is already seem to be
> >> present there) based on destroy_vm(). Then we'll see how it works with
> >> the launcher.
> >>
> >> Thanks,
> >> Andrey.
> >>
> >>
> >> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> >> > This has been my thinking - even if not perfect, lets get it working
> >> > using the launcher and then fix as required.  It's arguable if that
> >> > "brokenness" matters at this point, and I think that there's plenty to
> >> > be gained from having it work via the launcher.
> >> >
> >> > geir
> >> >
> >> > Rana Dasgupta wrote:
> >> > > create_vm() looks quite close/complete to being a complete
> >> prototype for
> >> > > CreateJavaVM,
> >> > > but I think more work is needed in DestroyVM which prototypes
> >> DestroyJavaVM
> >> > > for functional completeness. It is non waiting on user threads, it
> >> does not
> >> > > send the corresponding JVMTI shutdown events, I also don't know if it
> >> > > handles shutdown hooks cleanly ( but these "may" not be critical
> >> right now
> >> > > for hooking up to the launcher ). What do you think?
> >> > >
> >> > > When I ran a non trivial test.. upto 32 threads instantiating a
> >> very large
> >> > > number of objects  with            -XcleanupOnExit which uses
> >> DestroyVM, it
> >> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> >> > >
> >> > > Thanks,
> >> > > Rana
> >> > >
> >> > >
> >> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >> > >
> >> > >> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
> >> > >> >and DestroyJavaVM functions.
> >> > >>
> >> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> >> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
> >> can be
> >> > >> >adopted for that purpose?
> >> > >> >Is there are any tricks and caveats one should be aware of before
> >> > >> >trying to produce CreateJavaVM from it?
> >> > >>
> >> > >> >I've also seen a prototype for DestroyJavaVM in
> >> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
> >> > >> >wait till all Java threads are completed.
> >> > >>
> >> > >> >Any more ideas what needs to be done to implement those?
> >> > >>
> >> > >> >Thanks,
> >> > >> >Andrey.
> >> > >>
> >> > >>
> >> > >>
> >> ---------------------------------------------------------------------
> >> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> > >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> > >> For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> > >>
> >> > >>
> >> > >
> >> >
> >> > ---------------------------------------------------------------------
> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> Andrey Chernyshev
> >> Intel Middleware Products Division
> >>
> >
> >
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Tim Ellison <t....@gmail.com>.
Andrey Chernyshev wrote:
> With some changes I was able to run the DRLVM with classlib's
> launcher. Here is what I did (you can see the experimental patch at
> http://issues.apache.org/jira/browse/HARMONY-857):
> 
> - I have added JNI_CreateJavaVM declaration to jni.h (guess it will be
> the most appropriate place for it);

The existing jni.h in the HDK's jdk/include directory already has those
definitions.  The JNI function definitions are, of course, required by
the class library / tooling code.  We should probably just share one
copy of that file.

> - Added a simple implementations for JNI_CreateJavaVM and
> DestroyJavaVM based on the existing create_vm and detroy_vm functions
> in the vmcore/init submodule.
> 
> - To make vmcore/init functions visible for vmcore/jni code, I have
> moved vmcore/init/init.h to vmcore/include;
> 
> - In parse_arguments.cpp, I had to silently ignore the option
> "_org.apache.harmony.vmi.portlib" which is passed by the launcher to
> VM for some reason, causing the DRLVM to complain about "unknown
> option".  What is the purpose of that option, should I process it
> differently?

(see below)

> After all, I was able to run the DRLVM under classlib's launcher on
> Windows with a command like:
> 
> Java.exe -vm:vmcore -vmdir:. Hello

Cool, they should be -X options, I'll change it in the launcher when
next in there.

> and even was able to run Eclipse IDE with it. VM seems to exit cleanly
> and didn't report any error messages.
> 
> Some of the remaining issues / observations are:
> 
> (1)
> DRLVM startup is organized a bit differently compared to the classlib
> launcher startup, namely – the DRLVM after creating VM runs a special
> class called VMStart which is, in it's turn, asynchronously calling
> the main() method of the user application in a separate thread.

That's an interesting design choice.  So it always runs the
VMStart#start() method as soon as the VM is created?  So how do you
implement JNI_CreateJavaVM (which must not do that)?

Our tools etc. will have custom launchers that run different classes in
the o.a.h.tools package.

> When we go with the classlib's launcher, the main() method is executed
> in the same thread where the JavaVM is created.
> What are the caveats with that?

Don't know, as you say the primordial thread does the JNI_CreateJavaVM
then goes on to CallStaticVoidMethod on the target's main().

> (2)
> If I pass a wrong app class name to the classlib launcher, drlvm
> reports class not found exception and then is crashed. This happens
> because the classlib launcher, once it fails to run the app class,
> reports an exception (with ExceptionDescribe) but doesn't clear it
> (doesn't call ExceptionClear). Then it immediately goes with
> DestroyJavaVM those current implementation in drlvm doesn't expect
> that there is some pending exception object in the TLS.

We can fix this in the launcher if you want, but cannot promise that
everyone else using the invocation API will do this for you.

> Eventually, destroy_vm fails with assert in the class loading code
> while resolving VMStart class (VMStart holds the Java part of the
> shutdown method), because it mistakenly picks up the ClassNotFound
> exception object. It is remaining from unsuccessful attempt of
> classlib launcher to run the app's class main method.
> 
> The question is, who's responsibility should be to clear the exception
> object in that case? I tend to think that classlib launcher should be
> doing this once it takes the responsibility to process the possible
> exceptions while running the app main class.

Ok, but I'd advise that the Destroy is made more robust too.

> (3)
> CreateJavaVM can only be called once for now – many internal data
> structures in DRLVM are kept as global variables (jni_env, java_vm,
> Global_Env e.t.c.).  Therefore, it will be hard to organize the
> multiple instances of JavaVM unless all these things are encapsulated
> somewhere (into JNIEnv?).

Too bad.

> (4)
> Launcher wants the vm dll in the "default" directory unless the option
> is specified. Should we realign the drlvm build output and move all
> dll's into the "default" subdir?

I'll let the different Harmony VM folk argue about who should be the
default ;-)  I agree that it should no longer be the IBM VME.

> (5)
> What to do with the "_org.apache.harmony.vmi.portlib" option that
> launcher is offering to VM?

So the laucher creates the portlib function table so it can do OS things
(like write NLS messages, and open the VM DLLs etc), it then passes the
portlib in to the VM as this argument.

You can choose to ignore it, but since you are required to return a
portlib from the VMI's GetPortLibrary call, you might as well just
remember it.

It would be more polite to remember the one you were given so that the
caller can install their own portlib functions and have them back again
onthe VMI calls.

> Most likely there are more issues that I'm overlooking at the moment.
> Please consider the suggested patch is a workaround to make the things
> working, I'm wondering if there is a more graceful way to do this.

Good work Andrey, keep sending the questions and patches!

Regards,
Tim


> Thanks,
> Andrey.
> 
> 
> On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
>> and also add implementation into DestroyVM (stub is already seem to be
>> present there) based on destroy_vm(). Then we'll see how it works with
>> the launcher.
>>
>> Thanks,
>> Andrey.
>>
>>
>> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>> > This has been my thinking - even if not perfect, lets get it working
>> > using the launcher and then fix as required.  It's arguable if that
>> > "brokenness" matters at this point, and I think that there's plenty to
>> > be gained from having it work via the launcher.
>> >
>> > geir
>> >
>> > Rana Dasgupta wrote:
>> > > create_vm() looks quite close/complete to being a complete
>> prototype for
>> > > CreateJavaVM,
>> > > but I think more work is needed in DestroyVM which prototypes
>> DestroyJavaVM
>> > > for functional completeness. It is non waiting on user threads, it
>> does not
>> > > send the corresponding JVMTI shutdown events, I also don't know if it
>> > > handles shutdown hooks cleanly ( but these "may" not be critical
>> right now
>> > > for hooking up to the launcher ). What do you think?
>> > >
>> > > When I ran a non trivial test.. upto 32 threads instantiating a
>> very large
>> > > number of objects  with            -XcleanupOnExit which uses
>> DestroyVM, it
>> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
>> > >
>> > > Thanks,
>> > > Rana
>> > >
>> > >
>> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
>> > >
>> > >> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
>> > >> >and DestroyJavaVM functions.
>> > >>
>> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
>> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp
>> can be
>> > >> >adopted for that purpose?
>> > >> >Is there are any tricks and caveats one should be aware of before
>> > >> >trying to produce CreateJavaVM from it?
>> > >>
>> > >> >I've also seen a prototype for DestroyJavaVM in
>> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
>> > >> >wait till all Java threads are completed.
>> > >>
>> > >> >Any more ideas what needs to be done to implement those?
>> > >>
>> > >> >Thanks,
>> > >> >Andrey.
>> > >>
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > >> For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> > >>
>> > >>
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>>
>> -- 
>> Andrey Chernyshev
>> Intel Middleware Products Division
>>
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
With some changes I was able to run the DRLVM with classlib's
launcher. Here is what I did (you can see the experimental patch at
http://issues.apache.org/jira/browse/HARMONY-857):

- I have added JNI_CreateJavaVM declaration to jni.h (guess it will be
the most appropriate place for it);

- Added a simple implementations for JNI_CreateJavaVM and
DestroyJavaVM based on the existing create_vm and detroy_vm functions
in the vmcore/init submodule.

- To make vmcore/init functions visible for vmcore/jni code, I have
moved vmcore/init/init.h to vmcore/include;

- In parse_arguments.cpp, I had to silently ignore the option
"_org.apache.harmony.vmi.portlib" which is passed by the launcher to
VM for some reason, causing the DRLVM to complain about "unknown
option".  What is the purpose of that option, should I process it
differently?


After all, I was able to run the DRLVM under classlib's launcher on
Windows with a command like:

Java.exe -vm:vmcore -vmdir:. Hello

and even was able to run Eclipse IDE with it. VM seems to exit cleanly
and didn't report any error messages.

Some of the remaining issues / observations are:

(1)
DRLVM startup is organized a bit differently compared to the classlib
launcher startup, namely – the DRLVM after creating VM runs a special
class called VMStart which is, in it's turn, asynchronously calling
the main() method of the user application in a separate thread.
When we go with the classlib's launcher, the main() method is executed
in the same thread where the JavaVM is created.
What are the caveats with that?

(2)
If I pass a wrong app class name to the classlib launcher, drlvm
reports class not found exception and then is crashed. This happens
because the classlib launcher, once it fails to run the app class,
reports an exception (with ExceptionDescribe) but doesn't clear it
(doesn't call ExceptionClear). Then it immediately goes with
DestroyJavaVM those current implementation in drlvm doesn't expect
that there is some pending exception object in the TLS.
Eventually, destroy_vm fails with assert in the class loading code
while resolving VMStart class (VMStart holds the Java part of the
shutdown method), because it mistakenly picks up the ClassNotFound
exception object. It is remaining from unsuccessful attempt of
classlib launcher to run the app's class main method.

The question is, who's responsibility should be to clear the exception
object in that case? I tend to think that classlib launcher should be
doing this once it takes the responsibility to process the possible
exceptions while running the app main class.

(3)
CreateJavaVM can only be called once for now – many internal data
structures in DRLVM are kept as global variables (jni_env, java_vm,
Global_Env e.t.c.).  Therefore, it will be hard to organize the
multiple instances of JavaVM unless all these things are encapsulated
somewhere (into JNIEnv?).

(4)
Launcher wants the vm dll in the "default" directory unless the option
is specified. Should we realign the drlvm build output and move all
dll's into the "default" subdir?

(5)
What to do with the "_org.apache.harmony.vmi.portlib" option that
launcher is offering to VM?

Most likely there are more issues that I'm overlooking at the moment.
Please consider the suggested patch is a workaround to make the things
working, I'm wondering if there is a more graceful way to do this.

Thanks,
Andrey.


On 7/11/06, Andrey Chernyshev <a....@gmail.com> wrote:
> OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
> and also add implementation into DestroyVM (stub is already seem to be
> present there) based on destroy_vm(). Then we'll see how it works with
> the launcher.
>
> Thanks,
> Andrey.
>
>
> On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> > This has been my thinking - even if not perfect, lets get it working
> > using the launcher and then fix as required.  It's arguable if that
> > "brokenness" matters at this point, and I think that there's plenty to
> > be gained from having it work via the launcher.
> >
> > geir
> >
> > Rana Dasgupta wrote:
> > > create_vm() looks quite close/complete to being a complete prototype for
> > > CreateJavaVM,
> > > but I think more work is needed in DestroyVM which prototypes DestroyJavaVM
> > > for functional completeness. It is non waiting on user threads, it does not
> > > send the corresponding JVMTI shutdown events, I also don't know if it
> > > handles shutdown hooks cleanly ( but these "may" not be critical right now
> > > for hooking up to the launcher ). What do you think?
> > >
> > > When I ran a non trivial test.. upto 32 threads instantiating a very large
> > > number of objects  with            -XcleanupOnExit which uses DestroyVM, it
> > > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> > >
> > > Thanks,
> > > Rana
> > >
> > >
> > > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> > >
> > >> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
> > >> >and DestroyJavaVM functions.
> > >>
> > >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> > >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp can be
> > >> >adopted for that purpose?
> > >> >Is there are any tricks and caveats one should be aware of before
> > >> >trying to produce CreateJavaVM from it?
> > >>
> > >> >I've also seen a prototype for DestroyJavaVM in
> > >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
> > >> >wait till all Java threads are completed.
> > >>
> > >> >Any more ideas what needs to be done to implement those?
> > >>
> > >> >Thanks,
> > >> >Andrey.
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> > >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >>
> > >>
> > >
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Andrey Chernyshev
> Intel Middleware Products Division
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
OK, so I'm going to add CreateJavaVM  into vm\vmcore\src\jni\jni.cpp
and also add implementation into DestroyVM (stub is already seem to be
present there) based on destroy_vm(). Then we'll see how it works with
the launcher.

Thanks,
Andrey.


On 7/11/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
> This has been my thinking - even if not perfect, lets get it working
> using the launcher and then fix as required.  It's arguable if that
> "brokenness" matters at this point, and I think that there's plenty to
> be gained from having it work via the launcher.
>
> geir
>
> Rana Dasgupta wrote:
> > create_vm() looks quite close/complete to being a complete prototype for
> > CreateJavaVM,
> > but I think more work is needed in DestroyVM which prototypes DestroyJavaVM
> > for functional completeness. It is non waiting on user threads, it does not
> > send the corresponding JVMTI shutdown events, I also don't know if it
> > handles shutdown hooks cleanly ( but these "may" not be critical right now
> > for hooking up to the launcher ). What do you think?
> >
> > When I ran a non trivial test.. upto 32 threads instantiating a very large
> > number of objects  with            -XcleanupOnExit which uses DestroyVM, it
> > exited cleanly. Maybe OK to hookup and fix bugs as we go.
> >
> > Thanks,
> > Rana
> >
> >
> > On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> >
> >> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
> >> >and DestroyJavaVM functions.
> >>
> >> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> >> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp can be
> >> >adopted for that purpose?
> >> >Is there are any tricks and caveats one should be aware of before
> >> >trying to produce CreateJavaVM from it?
> >>
> >> >I've also seen a prototype for DestroyJavaVM in
> >> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
> >> >wait till all Java threads are completed.
> >>
> >> >Any more ideas what needs to be done to implement those?
> >>
> >> >Thanks,
> >> >Andrey.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Geir Magnusson Jr <ge...@pobox.com>.
This has been my thinking - even if not perfect, lets get it working
using the launcher and then fix as required.  It's arguable if that
"brokenness" matters at this point, and I think that there's plenty to
be gained from having it work via the launcher.

geir

Rana Dasgupta wrote:
> create_vm() looks quite close/complete to being a complete prototype for
> CreateJavaVM,
> but I think more work is needed in DestroyVM which prototypes DestroyJavaVM
> for functional completeness. It is non waiting on user threads, it does not
> send the corresponding JVMTI shutdown events, I also don't know if it
> handles shutdown hooks cleanly ( but these "may" not be critical right now
> for hooking up to the launcher ). What do you think?
> 
> When I ran a non trivial test.. upto 32 threads instantiating a very large
> number of objects  with            -XcleanupOnExit which uses DestroyVM, it
> exited cleanly. Maybe OK to hookup and fix bugs as we go.
> 
> Thanks,
> Rana
> 
> 
> On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
> 
>> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
>> >and DestroyJavaVM functions.
>>
>> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
>> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp can be
>> >adopted for that purpose?
>> >Is there are any tricks and caveats one should be aware of before
>> >trying to produce CreateJavaVM from it?
>>
>> >I've also seen a prototype for DestroyJavaVM in
>> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
>> >wait till all Java threads are completed.
>>
>> >Any more ideas what needs to be done to implement those?
>>
>> >Thanks,
>> >Andrey.
>>
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Alexey Varlamov <al...@gmail.com>.
Also there is destroy_vm(), which I guess even more close to what is
needed to prototype DestroyJavaVM.
Anyway, current DRLVM shutdown is tied closely with termination of the
main thread, leaving little chance for launcher cleanup. This is not a
blocker for now, but the shutdown certainly is the area for design
improvements in future.

--
Regards,
Alexey

2006/7/11, Rana Dasgupta <rd...@gmail.com>:
> create_vm() looks quite close/complete to being a complete prototype for
> CreateJavaVM,
> but I think more work is needed in DestroyVM which prototypes DestroyJavaVM
> for functional completeness. It is non waiting on user threads, it does not
> send the corresponding JVMTI shutdown events, I also don't know if it
> handles shutdown hooks cleanly ( but these "may" not be critical right now
> for hooking up to the launcher ). What do you think?
>
> When I ran a non trivial test.. upto 32 threads instantiating a very large
> number of objects  with            -XcleanupOnExit which uses DestroyVM, it
> exited cleanly. Maybe OK to hookup and fix bugs as we go.
>
> Thanks,
> Rana
>
>
> On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:
>
> > >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
> > >and DestroyJavaVM functions.
> >
> > >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> > >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp can be
> > >adopted for that purpose?
> > >Is there are any tricks and caveats one should be aware of before
> > >trying to produce CreateJavaVM from it?
> >
> > >I've also seen a prototype for DestroyJavaVM in
> > >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
> > >wait till all Java threads are completed.
> >
> > >Any more ideas what needs to be done to implement those?
> >
> > >Thanks,
> > >Andrey.
> >
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Rana Dasgupta <rd...@gmail.com>.
create_vm() looks quite close/complete to being a complete prototype for
CreateJavaVM,
but I think more work is needed in DestroyVM which prototypes DestroyJavaVM
for functional completeness. It is non waiting on user threads, it does not
send the corresponding JVMTI shutdown events, I also don't know if it
handles shutdown hooks cleanly ( but these "may" not be critical right now
for hooking up to the launcher ). What do you think?

When I ran a non trivial test.. upto 32 threads instantiating a very large
number of objects  with            -XcleanupOnExit which uses DestroyVM, it
exited cleanly. Maybe OK to hookup and fix bugs as we go.

Thanks,
Rana


On 7/10/06, Andrey Chernyshev <a....@gmail.com> wrote:

> >Yes, it seems like the launcher will need at least JNI_CreateJavaVM
> >and DestroyJavaVM functions.
>
> >I couldn't find implementation for CreateJavaVM in drlvm codebase.
> >Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp can be
> >adopted for that purpose?
> >Is there are any tricks and caveats one should be aware of before
> >trying to produce CreateJavaVM from it?
>
> >I've also seen a prototype for DestroyJavaVM in
> >vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
> >wait till all Java threads are completed.
>
> >Any more ideas what needs to be done to implement those?
>
> >Thanks,
> >Andrey.
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

Re: [drlvm] using the harmony launcher

Posted by Andrey Chernyshev <a....@gmail.com>.
On 7/10/06, Ivan Volosyuk <iv...@gmail.com> wrote:
> Classlib, of cause :)
>
> On 7/10/06, Ivan Volosyuk <iv...@gmail.com> wrote:
> > Invocation API is missing in DRLVM. It should be implemented.

Yes, it seems like the launcher will need at least JNI_CreateJavaVM
and DestroyJavaVM functions.

I couldn't find implementation for CreateJavaVM in drlvm codebase.
Perhaps create_vm() function in vm\vmcore\src\init\vm_main.cpp can be
adopted for that purpose?
Is there are any tricks and caveats one should be aware of before
trying to produce CreateJavaVM from it?

I've also seen a prototype for DestroyJavaVM in
vm\vmcore\src\init\vm.cpp - comment says it needs to be improved to
wait till all Java threads are completed.

Any more ideas what needs to be done to implement those?

Thanks,
Andrey.


> > Launcher should be updated:
> >  >>  char defaultDllName[] = "clearvm";
> >
> > p.s. Invocation api is really good todo item. I'm looking forward to
> > see browser plugin using DRLVM with classpath.
> > --
> > Ivan
> >
> > On 7/10/06, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> > > What is required to get the DRLVM use the Harmony launcher ?
> > >
> > > geir
> >
> > --
> > Ivan
> > Intel Middleware Products Division
> >
>
>
> --
> Ivan
> Intel Middleware Products Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Ivan Volosyuk <iv...@gmail.com>.
Classlib, of cause :)

On 7/10/06, Ivan Volosyuk <iv...@gmail.com> wrote:
> Invocation API is missing in DRLVM. It should be implemented.
> Launcher should be updated:
>  >>  char defaultDllName[] = "clearvm";
>
> p.s. Invocation api is really good todo item. I'm looking forward to
> see browser plugin using DRLVM with classpath.
> --
> Ivan
>
> On 7/10/06, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> > What is required to get the DRLVM use the Harmony launcher ?
> >
> > geir
>
> --
> Ivan
> Intel Middleware Products Division
>


-- 
Ivan
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [drlvm] using the harmony launcher

Posted by Ivan Volosyuk <iv...@gmail.com>.
Invocation API is missing in DRLVM. It should be implemented.
Launcher should be updated:
 >>  char defaultDllName[] = "clearvm";

p.s. Invocation api is really good todo item. I'm looking forward to
see browser plugin using DRLVM with classpath.
--
Ivan

On 7/10/06, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> What is required to get the DRLVM use the Harmony launcher ?
>
> geir

-- 
Ivan
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org