You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Stefan Horochovec <st...@gmail.com> on 2012/03/07 17:20:17 UTC

API for reflection

Hello everybody!

I don´t know if this issue was discussed at some point in the list,
but I would suggest the implementation of the Reflection natively to
the SDK.

Today, the as3-commons-reflect [1] is widely used, but I believe the
best option would be to add this feature natively.

What do you think of this demand?

[1] http://www.as3commons.org/as3-commons-reflect/index.html

-- 
Stefan Horochovec
Software Engineer
Blog: http://www.horochovec.com.br/
Twitter: http://twitter.com/horochovec

RE: API for reflection

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
>Mike, did you take any measurements?  Was the reflection data static or per-instance?  I would expect that the traits information for properties would be as efficient or more efficient than metadata.  And the >memory overhead of describetype would outweigh the memory of data structure.

Yes, but I was only looking at items labeled with Inject so my problem space was smaller. I have not tried to do a general purpose version so I don't have a 1:1 comparison with describeType which is obviously gathering a lot more. Extrapolating from what I did see, it is much more efficient than storing all of the metadata. My point on opting in was that in increase should we automatically use this method AND someone also still uses describeType at all.

As far as storage, it was static data. Effectively, again my goal at the time being very single purpose, for each class that had Injection points it stored a reference to that Class as well as the properties and methods labeled with Injection in three arrays (one for constructor arguments, one for fields, one for methods). In my particular case, I would also recursively store the same information for classes referenced as types herein, meaning that if one of the constructor arguments was of type ClassA then I also recorded this same data as I was attempting to optimize recursive object graph builds.

Mike


Re: API for reflection

Posted by Alex Harui <ah...@adobe.com>.


On 3/8/12 10:38 AM, "Michael A. Labriola" <la...@digitalprimates.net>
wrote:

>> Sounds like a plan! :) Can't wait to see what you've been up to :)
> 
> IMO, this is just the place to handle these things. It does mean we build more
> data structures and that does mean more memory use. However, I think we could
> let people opt out of that tradeoff.
> 
Mike, did you take any measurements?  Was the reflection data static or
per-instance?  I would expect that the traits information for properties
would be as efficient or more efficient than metadata.  And the memory
overhead of describetype would outweigh the memory of data structure.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


RE: API for reflection

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
>Sounds like a plan! :) Can't wait to see what you've been up to :)

IMO, this is just the place to handle these things. It does mean we build more data structures and that does mean more memory use. However, I think we could let people opt out of that tradeoff.

I have a really simple Guice style injector that I wrote to take advantage of these classes. It's a very fast (runtime) approach and allows for things like recursive identification of dependencies at startup without inspecting every class, which was a big win.

Mike

Re: API for reflection

Posted by Roland Zwaga <ro...@stackandheap.com>.
>
> >Having the compiler add this kind of reflection info would be awesome.
>
> As soon as we have compiler bits in SVN I can share what I have done. It
> is no way production worthy, however, this was the basis of the work I did
> to make injection more performant in the SDK itself.
>
> I identify kept metadata and provide a wrapper set of classes, etc. Right
> now it is not general purpose, it was just to identify Injection points.
> However, the theory described here is basically my approach.
>

Sounds like a plan! :) Can't wait to see what you've been up to :)

Roland

RE: API for reflection

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
>Having the compiler add this kind of reflection info would be awesome.

As soon as we have compiler bits in SVN I can share what I have done. It is no way production worthy, however, this was the basis of the work I did to make injection more performant in the SDK itself.

I identify kept metadata and provide a wrapper set of classes, etc. Right now it is not general purpose, it was just to identify Injection points. However, the theory described here is basically my approach.

Mike

Re: API for reflection

Posted by Roland Zwaga <ro...@stackandheap.com>.
>
> > to be precise, reflection is present in flash player (via
> > describetype) but the queries about structure of some class are not
> > cached, and accessible as xml not as a collection or something
> > similar.
> And performance of describetype is poor and probably the lowest priority
> feature of the VM.  Getting the compiler to add whatever you wanted from
> describetype as properties on the class would speed it up significantly.


Having the compiler add this kind of reflection info would be awesome.
as3commons-bytecode, for example, wouldn't need to
parse the loaded SWF anymore in order to generate runtime dynamic
properties.
I agree that as3commons-reflect probably shouldn't need to be part of the
SDK, if the SDK itself doesn't need the reflection
bits then it shouldn't be a part of it, people can just use as3-reflect.
Having the compiler support better reflection would be such an amazing
improvement though, we could  a Flex extension to
as3commons-reflect that uses those extra features. That way pure
actionscript projects could keep on using the 'regular'
as3-reflect classes while Flex apps could leverage the new reflection
functions.

cheers,

Roland
(FYI, I run the as3commons project)

Re: API for reflection

Posted by Alex Harui <ah...@adobe.com>.


On 3/8/12 8:12 AM, "Jarosław Szczepankiewicz" <js...@gmail.com>
wrote:

> to be precise, reflection is present in flash player (via
> describetype) but the queries about structure of some class are not
> cached, and accessible as xml not as a collection or something
> similar.
And performance of describetype is poor and probably the lowest priority
feature of the VM.  Getting the compiler to add whatever you wanted from
describetype as properties on the class would speed it up significantly.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: API for reflection

Posted by Jarosław Szczepankiewicz <js...@gmail.com>.
to be precise, reflection is present in flash player (via
describetype) but the queries about structure of some class are not
cached, and accessible as xml not as a collection or something
similar.

2012/3/7 Alex Harui <ah...@adobe.com>:
>
>
>
> On 3/7/12 9:08 AM, "Stefan Horochovec" <st...@gmail.com> wrote:
>
>> Well
>>
>> In my previous email I suggested was a reflection API built into the
>> Flex SDK, and also cited an example a third API that does this, but at
>> no time I said that we should copy, request that was donated, so I
>> suggested that was developed this feature natively, as there is in
>> Java eg
>> http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/package-summary
>> .html
> Reflection should probably be a VM feature, which it isn't, and I don't see
> it happening soon.  That doesn't mean that we can't tweak the compiler to
> add additional properties to classes under some convention so you can get
> most of what you want.
>>
>> Anyway, the idea was not well regarded? No problem, as I said, it was
>> just an idea launched. And after that, I sent an email wondering what
>> is the main focus at this time to work on the SDK. Also, ask if it was
>> that the development of Spark is still lacking a lot compared to Halo.
> There is no "official" focus.  Some folks will work on Spark, some will work
> on 3.x, some will be working on Maven integration, some will work on the
> compiler, some will work on targeting other platforms, etc.
>
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>

Re: API for reflection

Posted by Alex Harui <ah...@adobe.com>.


On 3/7/12 9:08 AM, "Stefan Horochovec" <st...@gmail.com> wrote:

> Well
> 
> In my previous email I suggested was a reflection API built into the
> Flex SDK, and also cited an example a third API that does this, but at
> no time I said that we should copy, request that was donated, so I
> suggested that was developed this feature natively, as there is in
> Java eg 
> http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/package-summary
> .html
Reflection should probably be a VM feature, which it isn't, and I don't see
it happening soon.  That doesn't mean that we can't tweak the compiler to
add additional properties to classes under some convention so you can get
most of what you want.
> 
> Anyway, the idea was not well regarded? No problem, as I said, it was
> just an idea launched. And after that, I sent an email wondering what
> is the main focus at this time to work on the SDK. Also, ask if it was
> that the development of Spark is still lacking a lot compared to Halo.
There is no "official" focus.  Some folks will work on Spark, some will work
on 3.x, some will be working on Maven integration, some will work on the
compiler, some will work on targeting other platforms, etc.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: API for reflection

Posted by Stefan Horochovec <st...@gmail.com>.
Well

In my previous email I suggested was a reflection API built into the
Flex SDK, and also cited an example a third API that does this, but at
no time I said that we should copy, request that was donated, so I
suggested that was developed this feature natively, as there is in
Java eg http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/package-summary.html

Anyway, the idea was not well regarded? No problem, as I said, it was
just an idea launched. And after that, I sent an email wondering what
is the main focus at this time to work on the SDK. Also, ask if it was
that the development of Spark is still lacking a lot compared to Halo.
Just that.

Att

-- 
Stefan Horochovec
Software Engineer
Blog: http://www.horochovec.com.br/
Twitter: http://twitter.com/horochovec

2012/3/7, Omar Gonzalez <s9...@apache.org>:
> On Wed, Mar 7, 2012 at 8:53 AM, Pierangelo Mancusi <
> pierangelo.mancusi@gmail.com> wrote:
>
>> i think Stefan said to implement in Sdk, not to import that project :-)
>>
>> good idea for me
>>
>
> Implement in what? Can you be more specific? What exactly do you want the
> reflection APIs implemented on? Just saying "implement X library" for the
> sake of using that library doesn't provide any direction into what or where
> it may improve something in particular.
>
>
>
> --
> Omar Gonzalez
> s9tpepper@apache.org
>

Re: API for reflection

Posted by Omar Gonzalez <s9...@apache.org>.
On Wed, Mar 7, 2012 at 8:53 AM, Pierangelo Mancusi <
pierangelo.mancusi@gmail.com> wrote:

> i think Stefan said to implement in Sdk, not to import that project :-)
>
> good idea for me
>

Implement in what? Can you be more specific? What exactly do you want the
reflection APIs implemented on? Just saying "implement X library" for the
sake of using that library doesn't provide any direction into what or where
it may improve something in particular.



-- 
Omar Gonzalez
s9tpepper@apache.org

Re: API for reflection

Posted by Pierangelo Mancusi <pi...@gmail.com>.
i think Stefan said to implement in Sdk, not to import that project :-)

good idea for me
Il giorno 07/mar/2012 17:47, "Stefan Horochovec" <
stefan.horochovec@gmail.com> ha scritto:

> Understand..
>
> In my mind went the idea of creating a more robust SDK, including
> some API that are required for various projects, but anyway, it was
> just an idea launched.
>
> The main focus is to supplement the missing components in the spark?
>
> Att
>
> --
> Stefan Horochovec
> Software Engineer
> Blog: http://www.horochovec.com.br/
> Twitter: http://twitter.com/horochovec
>
>
>
> 2012/3/7, Gilmar José Purin <gi...@gmail.com>:
> > I agree with Mike, people can use it without flex framework.
> >
> > Gilmar.
> > On Mar 7, 2012 1:23 PM, "Michael A. Labriola" <
> labriola@digitalprimates.net>
> > wrote:
> >
> >> >Today, the as3-commons-reflect [1] is widely used, but I believe the
> best
> >> option would be to add this feature natively.
> >>
> >> I disagree. That project has many uses and a lifetime far outside of the
> >> Flex framework. That would mean everyone interested in those APIs would
> >> need to use the Flex SDK (if it moved here) or there would be two copies
> >> of
> >> code that need to be kept in sync (a man with two watches never knows
> what
> >> time it is)
> >>
> >> Mike
> >>
> >>
> >
>

Re: API for reflection

Posted by Omar Gonzalez <s9...@apache.org>.
On Wed, Mar 7, 2012 at 8:59 AM, Brent Arnold <br...@brentarnold.com> wrote:

> I believe the purpose of this mailing list and project is to allow for
> lazy consensus on additions/updates to the Apache Flex SDK.
>

I agree here.


>
> I don't think there's anything wrong with people suggesting
> changes/updates/additions, they just need to back it up with code so the
> community can act on it. So if you are a project committer, or convince one
> to commit it for you, people can vote and discuss.
>

> Brent "not a committer" Arnold



I don't think there's anything wrong with it either. But like I said in my
last email on this thread, giving suggestions as to where something should
be changed, or how a particular library could benefit the Flex SDK, makes
it easier to understand where the suggestion is coming from so we can have
some real discussion on whether its a good idea to try and implement said
APIs. Right now an example of where or how the AS3Commons Reflection APIs
would benefit Flex SDK would be a good start. I can't think of anything in
particular myself.

-- 
Omar Gonzalez
s9tpepper@apache.org

Re: API for reflection

Posted by Brent Arnold <br...@brentarnold.com>.
I believe the purpose of this mailing list and project is to allow for 
lazy consensus on additions/updates to the Apache Flex SDK.

I don't think there's anything wrong with people suggesting 
changes/updates/additions, they just need to back it up with code so the 
community can act on it. So if you are a project committer, or convince 
one to commit it for you, people can vote and discuss.

Brent "not a committer" Arnold

On 3/7/12 9:52 AM, Omar Gonzalez wrote:
>> The main focus is to supplement the missing components in the spark?
>>
>> Att
>>
>> --
>> Stefan Horochovec
>> Software Engineer
>> Blog: http://www.horochovec.com.br/
>> Twitter: http://twitter.com/horochovec
>>
>>
> The main focus is to continue to move the Flex SDK forward, Spark, MX and
> future versions and architecture.
>
> There really wouldn't be any benefit to bringing those reflection APIs into
> the Flex SDK. Now, if you could petition and convince Adobe themselves to
> support the as3commons reflection libraries natively in AS3 that could
> speed them up and have real improvements. However, this mailing list is for
> Flex SDK development and is not directly affiliated with Adobe in regards
> to the Flash Player. I would post your suggestion on their Adobe Ideas
> site, but you should think of use cases that relate particularly to Gaming
> and Video if you want Adobe to pay any attention.
>
> Just my two cents.
>

Re: API for reflection

Posted by Omar Gonzalez <s9...@apache.org>.
>
> The main focus is to supplement the missing components in the spark?
>
> Att
>
> --
> Stefan Horochovec
> Software Engineer
> Blog: http://www.horochovec.com.br/
> Twitter: http://twitter.com/horochovec
>
>
The main focus is to continue to move the Flex SDK forward, Spark, MX and
future versions and architecture.

There really wouldn't be any benefit to bringing those reflection APIs into
the Flex SDK. Now, if you could petition and convince Adobe themselves to
support the as3commons reflection libraries natively in AS3 that could
speed them up and have real improvements. However, this mailing list is for
Flex SDK development and is not directly affiliated with Adobe in regards
to the Flash Player. I would post your suggestion on their Adobe Ideas
site, but you should think of use cases that relate particularly to Gaming
and Video if you want Adobe to pay any attention.

Just my two cents.

-- 
Omar Gonzalez
s9tpepper@apache.org

Re: API for reflection

Posted by Stefan Horochovec <st...@gmail.com>.
Understand..

In my mind went the idea of ​​creating a more robust SDK, including
some API that are required for various projects, but anyway, it was
just an idea launched.

The main focus is to supplement the missing components in the spark?

Att

-- 
Stefan Horochovec
Software Engineer
Blog: http://www.horochovec.com.br/
Twitter: http://twitter.com/horochovec



2012/3/7, Gilmar José Purin <gi...@gmail.com>:
> I agree with Mike, people can use it without flex framework.
>
> Gilmar.
> On Mar 7, 2012 1:23 PM, "Michael A. Labriola" <la...@digitalprimates.net>
> wrote:
>
>> >Today, the as3-commons-reflect [1] is widely used, but I believe the best
>> option would be to add this feature natively.
>>
>> I disagree. That project has many uses and a lifetime far outside of the
>> Flex framework. That would mean everyone interested in those APIs would
>> need to use the Flex SDK (if it moved here) or there would be two copies
>> of
>> code that need to be kept in sync (a man with two watches never knows what
>> time it is)
>>
>> Mike
>>
>>
>

RE: API for reflection

Posted by Gilmar José Purin <gi...@gmail.com>.
I agree with Mike, people can use it without flex framework.

Gilmar.
On Mar 7, 2012 1:23 PM, "Michael A. Labriola" <la...@digitalprimates.net>
wrote:

> >Today, the as3-commons-reflect [1] is widely used, but I believe the best
> option would be to add this feature natively.
>
> I disagree. That project has many uses and a lifetime far outside of the
> Flex framework. That would mean everyone interested in those APIs would
> need to use the Flex SDK (if it moved here) or there would be two copies of
> code that need to be kept in sync (a man with two watches never knows what
> time it is)
>
> Mike
>
>

Re: API for reflection

Posted by Omar Gonzalez <om...@gmail.com>.
Agree with Mike here. I think primarily Flex is an application component
set. If we start trying to put everything and the kitchen sink into it it's
going to turn into Zend Framework, and that's kind of a mess.

-omar

RE: API for reflection

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
>Today, the as3-commons-reflect [1] is widely used, but I believe the best option would be to add this feature natively.

I disagree. That project has many uses and a lifetime far outside of the Flex framework. That would mean everyone interested in those APIs would need to use the Flex SDK (if it moved here) or there would be two copies of code that need to be kept in sync (a man with two watches never knows what time it is)

Mike