You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Martijn Dashorst <ma...@gmail.com> on 2015/10/06 11:15:53 UTC

[wicket8] Lambdas everywhere (just models for now)

I've created a Lambdas class that compiles just fine in ECJ but fails
using javac.

https://gist.github.com/dashorst/da876be2f01770e862a5

The benefit of this way is that we don't perpetuate SerializableFoo
(Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
require that the passed in stuff is in fact serializable.

This way companies that have their own SerializableFunction et al, kan
pass those references into our Lambda models.

Unfortunately this is currently way beyond the capabilities of javac.

Check out the code above (the signature is quite hard to read, but in
use it is awesome, just use Eclipse 4.5.1)

Martijn

-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Michael Mosmann <mi...@mosmann.de>.
Hi,

.. did some further testing .. and got this conclusion. AFAIK you can
not have something like

  <X extends Function<S,D> & Serializable,S,D> foo(X func)

and expect the compiler doing the magic on this code

  foo(x -> x+1)

.. you must use a cast, so you have to write

 foo((Function<Integer,Integer> & Serializable) x -> x+1)

which gives no benefit over using something like our own Interface
extending Function, Supplier etc.

maybe i am wrong...

michael:)

Am 10.10.2015 um 12:01 schrieb Michael Mosmann:
> Hi,
> 
> ... if we using SerializableFunction instead of Function & Serializable,
> it will work. Works well with Wicket 7.0.0 on java8 (tested).
> 
> Michael
> 
> Am 07.10.2015 um 10:26 schrieb Jonas:
>> We experimented with lambda based IModels when Java 8 was released. Bottom
>> line was that serializable Lambdas are quite a problem. Both javac and ecj
>> had (and probably still have) lots of bugs related to serializable lambdas.
>> Another problematic area was obfuscation. There wasn't any easy way to let
>> proguard handle lambda based IModels without actually excluding all those
>> classes from obfuscation. This was what made us finally abandon the idea of
>> lambda based IModels, at least for now.
>>
>> cheers,
>> Jonas
>>
>>
>> On Tue, Oct 6, 2015 at 11:55 PM, Michael Mosmann <mi...@mosmann.de> wrote:
>>
>>> Maybe this is useful:
>>> https://github.com/flapdoodle-oss/de.flapdoodle.wicket/blob/master/models/src/test/java/de/flapdoodle/wicket/model/TestModelTransformations.java
>>> .. The model code should work with java8 and lambdas...
>>>
>>> Mm:)
>>>
>>> Am 6. Oktober 2015 23:37:34 MESZ, schrieb Michael Mosmann <
>>> michael@mosmann.de>:
>>>> I am not sure about the generic stuff... If you write only lamdas there
>>>> will be no issue..but if you reuse some code, there could be some need
>>>> of 'super' in it..
>>>>
>>>> But that's nothing i can build in my mind.. I need something like
>>>> eclipse to make it right. So maybe next week.. :)
>>>>
>>>> Mm:)
>>>>
>>>>
>>>> Am 6. Oktober 2015 22:48:32 MESZ, schrieb Martin Grigorov
>>>> <mg...@apache.org>:
>>>>> /me likes !!!
>>>>>
>>>>> Once it is buildable with javac:
>>>>>
>>>>> *) Since it doesn't need changes in any of the current Wicket classes
>>>> I
>>>>> think it could be added to WicketStuff 7.x and battle tested until
>>>>> Wicket
>>>>> 8.0.0 is out.
>>>>>
>>>>> *) What is the purpose of WriteOnlyModel?
>>>>> My concern is that Wicket will fail every time such model is used in a
>>>>> component when this component is being rendered.
>>>>>
>>>>> *) I think you have to name some of the methods #map and #flatMap, and
>>>>> add
>>>>> "Monad" somewhere in the javadoc. Just to make it more fancy :-)
>>>>>
>>>>> Martin Grigorov
>>>>> Wicket Training and Consulting
>>>>> https://twitter.com/mtgrigorov
>>>>>
>>>>> On Tue, Oct 6, 2015 at 11:15 AM, Martijn Dashorst <
>>>>> martijn.dashorst@gmail.com> wrote:
>>>>>
>>>>>> I've created a Lambdas class that compiles just fine in ECJ but
>>>> fails
>>>>>> using javac.
>>>>>>
>>>>>> https://gist.github.com/dashorst/da876be2f01770e862a5
>>>>>>
>>>>>> The benefit of this way is that we don't perpetuate SerializableFoo
>>>>>> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
>>>>>> require that the passed in stuff is in fact serializable.
>>>>>>
>>>>>> This way companies that have their own SerializableFunction et al,
>>>>> kan
>>>>>> pass those references into our Lambda models.
>>>>>>
>>>>>> Unfortunately this is currently way beyond the capabilities of
>>>> javac.
>>>>>>
>>>>>> Check out the code above (the signature is quite hard to read, but
>>>> in
>>>>>> use it is awesome, just use Eclipse 4.5.1)
>>>>>>
>>>>>> Martijn
>>>>>>
>>>>>> --
>>>>>> Become a Wicket expert, learn from the best:
>>>>> http://wicketinaction.com
>>>>>>
>>>>
>>>> --
>>>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>>>> gesendet.
>>>
>>> --
>>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>>> gesendet.
>>>
>>
> 


Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Michael Mosmann <mi...@mosmann.de>.
Hi,

... if we using SerializableFunction instead of Function & Serializable,
it will work. Works well with Wicket 7.0.0 on java8 (tested).

Michael

Am 07.10.2015 um 10:26 schrieb Jonas:
> We experimented with lambda based IModels when Java 8 was released. Bottom
> line was that serializable Lambdas are quite a problem. Both javac and ecj
> had (and probably still have) lots of bugs related to serializable lambdas.
> Another problematic area was obfuscation. There wasn't any easy way to let
> proguard handle lambda based IModels without actually excluding all those
> classes from obfuscation. This was what made us finally abandon the idea of
> lambda based IModels, at least for now.
> 
> cheers,
> Jonas
> 
> 
> On Tue, Oct 6, 2015 at 11:55 PM, Michael Mosmann <mi...@mosmann.de> wrote:
> 
>> Maybe this is useful:
>> https://github.com/flapdoodle-oss/de.flapdoodle.wicket/blob/master/models/src/test/java/de/flapdoodle/wicket/model/TestModelTransformations.java
>> .. The model code should work with java8 and lambdas...
>>
>> Mm:)
>>
>> Am 6. Oktober 2015 23:37:34 MESZ, schrieb Michael Mosmann <
>> michael@mosmann.de>:
>>> I am not sure about the generic stuff... If you write only lamdas there
>>> will be no issue..but if you reuse some code, there could be some need
>>> of 'super' in it..
>>>
>>> But that's nothing i can build in my mind.. I need something like
>>> eclipse to make it right. So maybe next week.. :)
>>>
>>> Mm:)
>>>
>>>
>>> Am 6. Oktober 2015 22:48:32 MESZ, schrieb Martin Grigorov
>>> <mg...@apache.org>:
>>>> /me likes !!!
>>>>
>>>> Once it is buildable with javac:
>>>>
>>>> *) Since it doesn't need changes in any of the current Wicket classes
>>> I
>>>> think it could be added to WicketStuff 7.x and battle tested until
>>>> Wicket
>>>> 8.0.0 is out.
>>>>
>>>> *) What is the purpose of WriteOnlyModel?
>>>> My concern is that Wicket will fail every time such model is used in a
>>>> component when this component is being rendered.
>>>>
>>>> *) I think you have to name some of the methods #map and #flatMap, and
>>>> add
>>>> "Monad" somewhere in the javadoc. Just to make it more fancy :-)
>>>>
>>>> Martin Grigorov
>>>> Wicket Training and Consulting
>>>> https://twitter.com/mtgrigorov
>>>>
>>>> On Tue, Oct 6, 2015 at 11:15 AM, Martijn Dashorst <
>>>> martijn.dashorst@gmail.com> wrote:
>>>>
>>>>> I've created a Lambdas class that compiles just fine in ECJ but
>>> fails
>>>>> using javac.
>>>>>
>>>>> https://gist.github.com/dashorst/da876be2f01770e862a5
>>>>>
>>>>> The benefit of this way is that we don't perpetuate SerializableFoo
>>>>> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
>>>>> require that the passed in stuff is in fact serializable.
>>>>>
>>>>> This way companies that have their own SerializableFunction et al,
>>>> kan
>>>>> pass those references into our Lambda models.
>>>>>
>>>>> Unfortunately this is currently way beyond the capabilities of
>>> javac.
>>>>>
>>>>> Check out the code above (the signature is quite hard to read, but
>>> in
>>>>> use it is awesome, just use Eclipse 4.5.1)
>>>>>
>>>>> Martijn
>>>>>
>>>>> --
>>>>> Become a Wicket expert, learn from the best:
>>>> http://wicketinaction.com
>>>>>
>>>
>>> --
>>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>>> gesendet.
>>
>> --
>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>> gesendet.
>>
> 


Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Jonas <ba...@gmail.com>.
We experimented with lambda based IModels when Java 8 was released. Bottom
line was that serializable Lambdas are quite a problem. Both javac and ecj
had (and probably still have) lots of bugs related to serializable lambdas.
Another problematic area was obfuscation. There wasn't any easy way to let
proguard handle lambda based IModels without actually excluding all those
classes from obfuscation. This was what made us finally abandon the idea of
lambda based IModels, at least for now.

cheers,
Jonas


On Tue, Oct 6, 2015 at 11:55 PM, Michael Mosmann <mi...@mosmann.de> wrote:

> Maybe this is useful:
> https://github.com/flapdoodle-oss/de.flapdoodle.wicket/blob/master/models/src/test/java/de/flapdoodle/wicket/model/TestModelTransformations.java
> .. The model code should work with java8 and lambdas...
>
> Mm:)
>
> Am 6. Oktober 2015 23:37:34 MESZ, schrieb Michael Mosmann <
> michael@mosmann.de>:
> >I am not sure about the generic stuff... If you write only lamdas there
> >will be no issue..but if you reuse some code, there could be some need
> >of 'super' in it..
> >
> >But that's nothing i can build in my mind.. I need something like
> >eclipse to make it right. So maybe next week.. :)
> >
> >Mm:)
> >
> >
> >Am 6. Oktober 2015 22:48:32 MESZ, schrieb Martin Grigorov
> ><mg...@apache.org>:
> >>/me likes !!!
> >>
> >>Once it is buildable with javac:
> >>
> >>*) Since it doesn't need changes in any of the current Wicket classes
> >I
> >>think it could be added to WicketStuff 7.x and battle tested until
> >>Wicket
> >>8.0.0 is out.
> >>
> >>*) What is the purpose of WriteOnlyModel?
> >>My concern is that Wicket will fail every time such model is used in a
> >>component when this component is being rendered.
> >>
> >>*) I think you have to name some of the methods #map and #flatMap, and
> >>add
> >>"Monad" somewhere in the javadoc. Just to make it more fancy :-)
> >>
> >>Martin Grigorov
> >>Wicket Training and Consulting
> >>https://twitter.com/mtgrigorov
> >>
> >>On Tue, Oct 6, 2015 at 11:15 AM, Martijn Dashorst <
> >>martijn.dashorst@gmail.com> wrote:
> >>
> >>> I've created a Lambdas class that compiles just fine in ECJ but
> >fails
> >>> using javac.
> >>>
> >>> https://gist.github.com/dashorst/da876be2f01770e862a5
> >>>
> >>> The benefit of this way is that we don't perpetuate SerializableFoo
> >>> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
> >>> require that the passed in stuff is in fact serializable.
> >>>
> >>> This way companies that have their own SerializableFunction et al,
> >>kan
> >>> pass those references into our Lambda models.
> >>>
> >>> Unfortunately this is currently way beyond the capabilities of
> >javac.
> >>>
> >>> Check out the code above (the signature is quite hard to read, but
> >in
> >>> use it is awesome, just use Eclipse 4.5.1)
> >>>
> >>> Martijn
> >>>
> >>> --
> >>> Become a Wicket expert, learn from the best:
> >>http://wicketinaction.com
> >>>
> >
> >--
> >Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
> >gesendet.
>
> --
> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
> gesendet.
>

Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Michael Mosmann <mi...@mosmann.de>.
Maybe this is useful: https://github.com/flapdoodle-oss/de.flapdoodle.wicket/blob/master/models/src/test/java/de/flapdoodle/wicket/model/TestModelTransformations.java .. The model code should work with java8 and lambdas... 

Mm:)

Am 6. Oktober 2015 23:37:34 MESZ, schrieb Michael Mosmann <mi...@mosmann.de>:
>I am not sure about the generic stuff... If you write only lamdas there
>will be no issue..but if you reuse some code, there could be some need
>of 'super' in it..
>
>But that's nothing i can build in my mind.. I need something like
>eclipse to make it right. So maybe next week.. :)
>
>Mm:)
>
>
>Am 6. Oktober 2015 22:48:32 MESZ, schrieb Martin Grigorov
><mg...@apache.org>:
>>/me likes !!!
>>
>>Once it is buildable with javac:
>>
>>*) Since it doesn't need changes in any of the current Wicket classes
>I
>>think it could be added to WicketStuff 7.x and battle tested until
>>Wicket
>>8.0.0 is out.
>>
>>*) What is the purpose of WriteOnlyModel?
>>My concern is that Wicket will fail every time such model is used in a
>>component when this component is being rendered.
>>
>>*) I think you have to name some of the methods #map and #flatMap, and
>>add
>>"Monad" somewhere in the javadoc. Just to make it more fancy :-)
>>
>>Martin Grigorov
>>Wicket Training and Consulting
>>https://twitter.com/mtgrigorov
>>
>>On Tue, Oct 6, 2015 at 11:15 AM, Martijn Dashorst <
>>martijn.dashorst@gmail.com> wrote:
>>
>>> I've created a Lambdas class that compiles just fine in ECJ but
>fails
>>> using javac.
>>>
>>> https://gist.github.com/dashorst/da876be2f01770e862a5
>>>
>>> The benefit of this way is that we don't perpetuate SerializableFoo
>>> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
>>> require that the passed in stuff is in fact serializable.
>>>
>>> This way companies that have their own SerializableFunction et al,
>>kan
>>> pass those references into our Lambda models.
>>>
>>> Unfortunately this is currently way beyond the capabilities of
>javac.
>>>
>>> Check out the code above (the signature is quite hard to read, but
>in
>>> use it is awesome, just use Eclipse 4.5.1)
>>>
>>> Martijn
>>>
>>> --
>>> Become a Wicket expert, learn from the best:
>>http://wicketinaction.com
>>>
>
>-- 
>Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>gesendet.

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Michael Mosmann <mi...@mosmann.de>.
I am not sure about the generic stuff... If you write only lamdas there will be no issue..but if you reuse some code, there could be some need of 'super' in it..

But that's nothing i can build in my mind.. I need something like eclipse to make it right. So maybe next week.. :)

Mm:)


Am 6. Oktober 2015 22:48:32 MESZ, schrieb Martin Grigorov <mg...@apache.org>:
>/me likes !!!
>
>Once it is buildable with javac:
>
>*) Since it doesn't need changes in any of the current Wicket classes I
>think it could be added to WicketStuff 7.x and battle tested until
>Wicket
>8.0.0 is out.
>
>*) What is the purpose of WriteOnlyModel?
>My concern is that Wicket will fail every time such model is used in a
>component when this component is being rendered.
>
>*) I think you have to name some of the methods #map and #flatMap, and
>add
>"Monad" somewhere in the javadoc. Just to make it more fancy :-)
>
>Martin Grigorov
>Wicket Training and Consulting
>https://twitter.com/mtgrigorov
>
>On Tue, Oct 6, 2015 at 11:15 AM, Martijn Dashorst <
>martijn.dashorst@gmail.com> wrote:
>
>> I've created a Lambdas class that compiles just fine in ECJ but fails
>> using javac.
>>
>> https://gist.github.com/dashorst/da876be2f01770e862a5
>>
>> The benefit of this way is that we don't perpetuate SerializableFoo
>> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
>> require that the passed in stuff is in fact serializable.
>>
>> This way companies that have their own SerializableFunction et al,
>kan
>> pass those references into our Lambda models.
>>
>> Unfortunately this is currently way beyond the capabilities of javac.
>>
>> Check out the code above (the signature is quite hard to read, but in
>> use it is awesome, just use Eclipse 4.5.1)
>>
>> Martijn
>>
>> --
>> Become a Wicket expert, learn from the best:
>http://wicketinaction.com
>>

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Martin Grigorov <mg...@apache.org>.
/me likes !!!

Once it is buildable with javac:

*) Since it doesn't need changes in any of the current Wicket classes I
think it could be added to WicketStuff 7.x and battle tested until Wicket
8.0.0 is out.

*) What is the purpose of WriteOnlyModel?
My concern is that Wicket will fail every time such model is used in a
component when this component is being rendered.

*) I think you have to name some of the methods #map and #flatMap, and add
"Monad" somewhere in the javadoc. Just to make it more fancy :-)

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Oct 6, 2015 at 11:15 AM, Martijn Dashorst <
martijn.dashorst@gmail.com> wrote:

> I've created a Lambdas class that compiles just fine in ECJ but fails
> using javac.
>
> https://gist.github.com/dashorst/da876be2f01770e862a5
>
> The benefit of this way is that we don't perpetuate SerializableFoo
> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
> require that the passed in stuff is in fact serializable.
>
> This way companies that have their own SerializableFunction et al, kan
> pass those references into our Lambda models.
>
> Unfortunately this is currently way beyond the capabilities of javac.
>
> Check out the code above (the signature is quite hard to read, but in
> use it is awesome, just use Eclipse 4.5.1)
>
> Martijn
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
>

Re: [wicket8] Lambdas everywhere (just models for now)

Posted by andrea del bene <an...@gmail.com>.
To be honest I use '&' so rarely to extend my classes that I almost 
forgot about it :-)

On 06/10/2015 11:30, Tobias Soloschenko wrote:
> Hi Martijn,
>
> my favorit:
>
> <T, X, Y, XY extends Function<X, Y> & Serializable, YT extends 
> Function<Y, T> & Serializable>
>
> :-D
>
> Anyway some places hard to read but the unit tests show the benefit!
>
> kind regards
>
> Tobias
>
> Am 06.10.15 um 11:15 schrieb Martijn Dashorst:
>> I've created a Lambdas class that compiles just fine in ECJ but fails
>> using javac.
>>
>> https://gist.github.com/dashorst/da876be2f01770e862a5
>>
>> The benefit of this way is that we don't perpetuate SerializableFoo
>> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
>> require that the passed in stuff is in fact serializable.
>>
>> This way companies that have their own SerializableFunction et al, kan
>> pass those references into our Lambda models.
>>
>> Unfortunately this is currently way beyond the capabilities of javac.
>>
>> Check out the code above (the signature is quite hard to read, but in
>> use it is awesome, just use Eclipse 4.5.1)
>>
>> Martijn
>>
>


Re: [wicket8] Lambdas everywhere (just models for now)

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi Martijn,

my favorit:

<T, X, Y, XY extends Function<X, Y> & Serializable, YT extends 
Function<Y, T> & Serializable>

:-D

Anyway some places hard to read but the unit tests show the benefit!

kind regards

Tobias

Am 06.10.15 um 11:15 schrieb Martijn Dashorst:
> I've created a Lambdas class that compiles just fine in ECJ but fails
> using javac.
>
> https://gist.github.com/dashorst/da876be2f01770e862a5
>
> The benefit of this way is that we don't perpetuate SerializableFoo
> (Foo==[Function, Consumer, Predicate, Supplier, ...]) but instead
> require that the passed in stuff is in fact serializable.
>
> This way companies that have their own SerializableFunction et al, kan
> pass those references into our Lambda models.
>
> Unfortunately this is currently way beyond the capabilities of javac.
>
> Check out the code above (the signature is quite hard to read, but in
> use it is awesome, just use Eclipse 4.5.1)
>
> Martijn
>