Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wonderfly opened this issue Jan 9, 2015 · 8 comments
Assignees
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.

Comments

@wonderfly
Copy link
Contributor

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

@wonderfly wonderfly added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. imported priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 9, 2015
@wonderfly wonderfly self-assigned this Jan 9, 2015
@wonderfly
Copy link
Contributor Author

From yan...@google.com on June 22, 2011 08:27:48

Status: Accepted
Labels: Component-Util Milestone-Version1.6.0

@wonderfly
Copy link
Contributor Author

From yan...@google.com on September 22, 2011 12:39:19

Labels: -Milestone-Version1.6.0 Milestone-Version1.7.0

@wonderfly
Copy link
Contributor Author

From yan...@google.com on February 28, 2012 17:13:52

Labels: Milestone-Version1.8.0

@wonderfly
Copy link
Contributor Author

From yan...@google.com on March 27, 2012 07:22:33

Labels: Milestone-Version1.9.0

@wonderfly
Copy link
Contributor Author

From rmis...@google.com on May 14, 2012 07:14:07

Labels: -Milestone-Version1.9.0 Milestone-Version1.10.0

@wonderfly
Copy link
Contributor Author

From yan...@google.com on May 30, 2012 15:05:06

Labels: -Milestone-Version1.10.0 Milestone-Version1.11.0

@wonderfly
Copy link
Contributor Author

From rmis...@google.com on July 17, 2012 07:34:16

http://codereview.appspot.com/6312057/

Status: Started
Owner: rmis...@google.com
Cc: yan...@google.com

@wonderfly
Copy link
Contributor Author

From rmis...@google.com on August 01, 2012 09:59:25

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant