« Return to Thread: Characteristics of objects instantiated in Groovy for pre-defined Java classes...

Re: Characteristics of objects instantiated in Groovy for pre-defined Java classes...

by Jeff Brown-14 :: Rate this Message:

Reply to Author | View in Thread

On Thu, Jul 2, 2009 at 9:59 PM, alopecoid<alopecoid@...> wrote:

> Hi,
>
> Let's say that I instantiate a pre-existing Java class within a Groovy
> script, and then hand the resulting object back to a Java program for
> further execution. Will the bytecode for the returned object type be
> the same as the original Java class bytecode, or has this bytecode
> undergone further instrumentation?
>
> For example, if I use Groovy strictly to "wire up" an application that
> is otherwise written in Java, will the resulting objects that were
> instantiated in Groovy have the same characteristics (think
> performance) had they been instantiated solely in Java?
>
> Thanks!


Yes, objects instantiated in Groovy code will have the same
characteristics as if they had been instantiated in Java code.  The
dynamic behavior of objects in Groovy doesn't really have to do with
where they are created but where they are being used.  For example,
when you make a method call from Groovy that method call goes through
the MOP.  It doesn't matter if the object was created by Java code or
Groovy code and it doesn't matter if the object is an instance of a
class written in Groovy or a class written in Java.  If you make a
method call on an object from Groovy, that call goes through the MOP.
The other way around... when you make a method call from Java, that
call will not go through the MOP, again without respect to where the
object was created or what language its class was written in.

Make sense?



jb

--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Characteristics of objects instantiated in Groovy for pre-defined Java classes...