When a subclass with a field annotated with @Key hides a superclass field annotated with @Key, prefer the definition from the subclass. #17
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
From dtbull...@gmail.com on June 22, 2011 08:06:43
Version of google-http-java-client
The one that's embedded in google-api-java-client 1.4.1-beta
Java environment (e.g. Java 6, Android 2.3, App Engine 1.4.3)?
All
Describe the problem.
package my.pkg;
class A {
@key
String foo;
}
class B extends A {
@key
Integer foo;
}
When attempting to anHttpResponse.parseAs(B.class), google-java-api-client complains like this:
java.lang.IllegalArgumentException: two fields have the same name : public java.lang.String my.pkg.A.foo and public java.lang.Integer my.pkg.B.foo
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115) ... etc.
How would you expect it to be fixed?
Because the intent of B.foo is to hide A.foo, google-http-java-client should only consider B.foo to be of interest for parsing, even though the java.lang.reflection API does give it complete information about the definitions of foo, and both classes use the @key annotation.
Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=17
The text was updated successfully, but these errors were encountered: