computerluca / lambdaj

Automatically exported from code.google.com/p/lambdaj
1 stars 0 forks source link

parent class methods not accessible in some cases #116

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a package-private parent class P with final field X, field 
constructor P(X x) and a public getter X getX().
2. Create a public child class C extends P.
3. call having(on(C.class).getX(), anyStringMatcher).

What is the expected output?

Lambda#having will return a matcher.

What do you see instead?

ch.lambdaj.function.argument.ArgumentConversionException: Unable to convert the 
placeholder null in a valid argument
at 
ch.lambdaj.function.argument.ArgumentsFactory.actualArgument(ArgumentsFactory.ja
va:76)
at 
ch.lambdaj.function.matcher.HasArgumentWithValue.havingValue(HasArgumentWithValu
e.java:70)
at ch.lambdaj.Lambda.having(Lambda.java:1204)
...

What version of the product are you using? On what operating system?

2.3.3
windows

Please provide any additional information below.

There are several solutions any of which circumvents the problem:
1) Override public getter in child class (inside call parent's getter, of 
course)
2) Create a no-arg constructor in child class (call super constructor with 
anything, can be nulls and zeros)
3) Declare parent class public

In my case, number 2 is the least-painful provided I add a comment explaining 
the cryptic no-arg constructor, but all of the above is dirty hacking because 
my classes have to be adjusted for outside usage using LambdaJ of which they 
know nothing.

Can this be avoided somehow?

Original issue reported on code.google.com by marko.bj...@gmail.com on 21 Jan 2014 at 4:37

GoogleCodeExporter commented 8 years ago
sorry, a typo:
anyStringMatcher should be anyXMatcher (any instance of Matcher<X>)

Original comment by marko.bj...@gmail.com on 21 Jan 2014 at 4:40