Closed GoogleCodeExporter closed 9 years ago
Original comment by kak@google.com
on 18 Feb 2014 at 3:09
Perhaps NullPointerTester (or one of the classes it uses) should be smart
enough to look for instances of a class in that class's static final fields.
If we instead handle MediaType specifically, I have some reservations about
whether we want to go down the road of adding default values for our types when
we don't personally need them. But I don't feel that strongly, and given that
this is the first request we've gotten that I can recall, I'm not too concerned.
(Also, Greg points out that a direct usage of MediaType would introduce a
testing->net dependency. Kevin and Christian suggest that we won't ever want a
net->testing dep, and I agree: There's no concern about circularity.)
Original comment by cpov...@google.com
on 18 Feb 2014 at 6:00
Ben, is this something that you've considered in the past...?
"Perhaps NullPointerTester (or one of the classes it uses) should be smart
enough to look for instances of a class in that class's static final fields."
Original comment by cpov...@google.com
on 18 Feb 2014 at 6:02
There seems to be a few different options. Ordering from the most specific to
more generic:
1. Just add default value for MediaType.
2. ArbitraryInstances can look for public-static-final fields of type Foo in
class Foo.
3. Why stop there? ArbitraryInstances can also look for zero-arg static factory
methods.
4. Why stop there? ArbitraryInstances also can look for public-static-final
fields in a class called "Foos".
ArbitraryInstances already look for zero-arg public constructors. So it doesn't
seem that out of line to expand the search to constants and factory methods.
The use of "Foos" is a bit of strech. Although it seems pretty common that
constants and factories live in a Foos class instead of the original Foo?
We probably need to get determinism right. Whichever field/factory we choose to
use among multiple choices, we don't want the choice to change when the source
code doesn't change. So picking the first from getDeclaredFields() or
getDeclaredMethods() isn't ideal.
Sorting by field/method name possibly will suffice.
Original comment by be...@google.com
on 18 Feb 2014 at 8:23
We went with "2. ArbitraryInstances can look for public-static-final fields of
type Foo in class Foo."
http://code.google.com/p/guava-libraries/source/detail?r=deff3845959d6be8b6eeb80
2d76b2b7637d1cc02
Original comment by cpov...@google.com
on 3 Mar 2014 at 3:11
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<issue id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:10
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:07
Original issue reported on code.google.com by
matt.nat...@gmail.com
on 14 Feb 2014 at 9:59