zhiqinghuang / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

ClassCastException when type does not have an empty constructor #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
when issuing forEach, for example on a collection of a type that does not
have a default constructor, a ClassCastException is thrown

I  would expect a better exception, like "target type %s does not have a
default constructor"

probably a better solution is to allow ProxyUtil to
createProxyForClassWithoutDefaultConstructor...

keep up the good work

Original issue reported on code.google.com by ronm...@gmail.com on 25 Jun 2009 at 9:22

GoogleCodeExporter commented 8 years ago

Original comment by mario.fu...@gmail.com on 26 Jun 2009 at 7:12

GoogleCodeExporter commented 8 years ago
See here for a solution, still using cglib. The guyes of EasyMock and jMock 
faced it
also;
http://jira.springframework.org/browse/SPR-285

Original comment by sebastian.jancke@googlemail.com on 26 Jun 2009 at 2:21

GoogleCodeExporter commented 8 years ago
It would be really great, if you can fix this issue (get rid of no-arg 
constructor),
otherwise this lib is of no use for a lot of people. The damage of a default 
no-arg
constructor is too high and inacceptable.

Original comment by sebastian.jancke@googlemail.com on 26 Jun 2009 at 2:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I've created a patch containing a fix for ProxyUtil (and of course a test 
case). It's
based on the work of mockito and jMock to create proxies of non-final classes 
without
default constructors.

The patch introduces a dependency upon objenesis-1.0 (also hosted here and e.g. 
used
in mockito).

This makes this library really wide-spread usable and more distinctive from 
other
similar projects like logicalpractice-collections.

Original comment by sebastian.jancke@googlemail.com on 29 Jun 2009 at 10:51

Attachments:

GoogleCodeExporter commented 8 years ago
sorry, cog server error's 500 from google... seems he still could upload.

Original comment by sebastian.jancke@googlemail.com on 29 Jun 2009 at 10:52

GoogleCodeExporter commented 8 years ago
Fixed in patch release 1.10 (thank to Sebastian Juncke)
Now it is possible to proxy a class even if it misses a no arg constuctor.

Original comment by mario.fu...@gmail.com on 1 Jul 2009 at 10:50