You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by ChadDavis <ch...@gmail.com> on 2009/02/18 01:03:59 UTC

iteration over a list broke from 1.4 - 1.6

This is interesting.  I just migrated from 1.4 to 1.6 and broke an
existing template.

That template iterated over a List returned by an Enum object.  The
following pseudo code shows what I'm doing.  Note, the getter that
returns the list
is an abstract member of the Thing enum.  Each of the defined
instances of this enum implement it.  This worked on velocity 1.4, but
doesn't on 1.6.  To get it to work on 1.6, I had to change the
abstract method to a normal method that each of the enum's override.
It guess this is some sort of reflection API issue.    Seems like it
should work as it did before to me.  Thoughts?


public enum Thing {

	    NUMBER_ONE(  ){
			public List<String> getInnerThings() {
				//initialize innerThings if this is first time
				if ( this.innerThings == null ) {
					innerThings = new ArrayList<String>();	
					innerThings.add( "blah blah" );
					innerThings.add("blah blah"  );
					
				}
				return innerThings;
			}
		},
		 NUMBER_TWO(  ){
			public List<String> getinnerThings() {
				//initialize innerThings if this is first time
				if ( this.innerThings == null ) {
					innerThings = new ArrayList<String>();	
					innerThings.add( "blah blah" );
					innerThings.add("blah blah"  );
					
				}
				return innerThings;

			}
		},
		 NUMBER_THREE(  ){
			public List<String> getinnerThings() {
				if ( this.innerThings == null ) {
					innerThings = new ArrayList<String>();	
					innerThings.add( "blah blah" );
					innerThings.add("blah blah"  );
					
				}
				return innerThings;

			}
		};


	List<String> innerThings;
	
	//This was an abstract method, but Velocity 1.6 quite working with it.
	public abstract List<String> getinnerThings();
	
	
}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: iteration over a list broke from 1.4 - 1.6

Posted by ChadDavis <ch...@gmail.com>.
No, it still doesn't work with 1.6.2.  I'll put the Jira in.

On Tue, Feb 17, 2009 at 5:13 PM, Nathan Bubna <nb...@gmail.com> wrote:
> Yeah, that is interesting.  Have you tried this with 1.6.2 perchance?
> There were a few fixes to method mapping.  I'm guessing this will
> still be broken, but i could be wrong.
>
> Here's the latest 1.6.2 test build:
> http://people.apache.org/~cbrisson/velocity/engine/1.6.2/
>
> If it is still failing in 1.6.2, you (or i) can open a JIRA issue for
> this, and i'll see if this is a fixable regression (keeping in mind
> that Velocity 1.x is still build against jdk 1.4).
>
> On Tue, Feb 17, 2009 at 4:03 PM, ChadDavis <ch...@gmail.com> wrote:
>> This is interesting.  I just migrated from 1.4 to 1.6 and broke an
>> existing template.
>>
>> That template iterated over a List returned by an Enum object.  The
>> following pseudo code shows what I'm doing.  Note, the getter that
>> returns the list
>> is an abstract member of the Thing enum.  Each of the defined
>> instances of this enum implement it.  This worked on velocity 1.4, but
>> doesn't on 1.6.  To get it to work on 1.6, I had to change the
>> abstract method to a normal method that each of the enum's override.
>> It guess this is some sort of reflection API issue.    Seems like it
>> should work as it did before to me.  Thoughts?
>>
>>
>> public enum Thing {
>>
>>            NUMBER_ONE(  ){
>>                        public List<String> getInnerThings() {
>>                                //initialize innerThings if this is first time
>>                                if ( this.innerThings == null ) {
>>                                        innerThings = new ArrayList<String>();
>>                                        innerThings.add( "blah blah" );
>>                                        innerThings.add("blah blah"  );
>>
>>                                }
>>                                return innerThings;
>>                        }
>>                },
>>                 NUMBER_TWO(  ){
>>                        public List<String> getinnerThings() {
>>                                //initialize innerThings if this is first time
>>                                if ( this.innerThings == null ) {
>>                                        innerThings = new ArrayList<String>();
>>                                        innerThings.add( "blah blah" );
>>                                        innerThings.add("blah blah"  );
>>
>>                                }
>>                                return innerThings;
>>
>>                        }
>>                },
>>                 NUMBER_THREE(  ){
>>                        public List<String> getinnerThings() {
>>                                if ( this.innerThings == null ) {
>>                                        innerThings = new ArrayList<String>();
>>                                        innerThings.add( "blah blah" );
>>                                        innerThings.add("blah blah"  );
>>
>>                                }
>>                                return innerThings;
>>
>>                        }
>>                };
>>
>>
>>        List<String> innerThings;
>>
>>        //This was an abstract method, but Velocity 1.6 quite working with it.
>>        public abstract List<String> getinnerThings();
>>
>>
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: iteration over a list broke from 1.4 - 1.6

Posted by Nathan Bubna <nb...@gmail.com>.
Yeah, that is interesting.  Have you tried this with 1.6.2 perchance?
There were a few fixes to method mapping.  I'm guessing this will
still be broken, but i could be wrong.

Here's the latest 1.6.2 test build:
http://people.apache.org/~cbrisson/velocity/engine/1.6.2/

If it is still failing in 1.6.2, you (or i) can open a JIRA issue for
this, and i'll see if this is a fixable regression (keeping in mind
that Velocity 1.x is still build against jdk 1.4).

On Tue, Feb 17, 2009 at 4:03 PM, ChadDavis <ch...@gmail.com> wrote:
> This is interesting.  I just migrated from 1.4 to 1.6 and broke an
> existing template.
>
> That template iterated over a List returned by an Enum object.  The
> following pseudo code shows what I'm doing.  Note, the getter that
> returns the list
> is an abstract member of the Thing enum.  Each of the defined
> instances of this enum implement it.  This worked on velocity 1.4, but
> doesn't on 1.6.  To get it to work on 1.6, I had to change the
> abstract method to a normal method that each of the enum's override.
> It guess this is some sort of reflection API issue.    Seems like it
> should work as it did before to me.  Thoughts?
>
>
> public enum Thing {
>
>            NUMBER_ONE(  ){
>                        public List<String> getInnerThings() {
>                                //initialize innerThings if this is first time
>                                if ( this.innerThings == null ) {
>                                        innerThings = new ArrayList<String>();
>                                        innerThings.add( "blah blah" );
>                                        innerThings.add("blah blah"  );
>
>                                }
>                                return innerThings;
>                        }
>                },
>                 NUMBER_TWO(  ){
>                        public List<String> getinnerThings() {
>                                //initialize innerThings if this is first time
>                                if ( this.innerThings == null ) {
>                                        innerThings = new ArrayList<String>();
>                                        innerThings.add( "blah blah" );
>                                        innerThings.add("blah blah"  );
>
>                                }
>                                return innerThings;
>
>                        }
>                },
>                 NUMBER_THREE(  ){
>                        public List<String> getinnerThings() {
>                                if ( this.innerThings == null ) {
>                                        innerThings = new ArrayList<String>();
>                                        innerThings.add( "blah blah" );
>                                        innerThings.add("blah blah"  );
>
>                                }
>                                return innerThings;
>
>                        }
>                };
>
>
>        List<String> innerThings;
>
>        //This was an abstract method, but Velocity 1.6 quite working with it.
>        public abstract List<String> getinnerThings();
>
>
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org