alwayswill / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

When a subclass with a field annotated with @Key hides a superclass field annotated with @Key, prefer the definition from the subclass. #238

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.4.1-beta)?
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 <foo>: 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-api-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 reported on code.google.com by dtbull...@gmail.com on 22 Jun 2011 at 5:00

GoogleCodeExporter commented 9 years ago
Would you kindly reopen this issue in this location?

http://code.google.com/p/google-http-java-client/issues/entry?template=Request%2
0a%20feature

All of the key parsing code has been moved over to the google-http-java-client 
project.  This will soon be released with version 1.5.

Original comment by yan...@google.com on 22 Jun 2011 at 2:29

GoogleCodeExporter commented 9 years ago
OK. http://code.google.com/p/google-http-java-client/issues/detail?id=17

Original comment by dtbull...@gmail.com on 22 Jun 2011 at 3:07