You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
You're right, but doing that removes the type constraint check for the arguments. My actual method has multiple arguments, each typed with <T>. What I did to solve it was exactly what you suggested, but I had an extra "internal" method that wasn't type safe. Btw, since the @SuprressWarnings annotation isn't copied, AA will produce code with warnings. Not a big issue, but still annoying. It was made extra annoying because the foo method was implementing an interface method.
I think my previous comment was not clear. You should not remove the type parameter from your code, because you lost type safety, etc. (Well, i know you have no other option until this is not fixed some way). The generated class by AA should remove the type parameter - in case of the generated class, it does not matter, because types are already checked in your code. By the way some AA code will produce warnings, a discussion started about this in #835.
@DayS, what do you think on my suggestion about generic type?
I think it should be easily enough to generate methods with provided generify types by doing only small changes. I already made a PoC and it seems to work fine.
But Codemodel currently doesn't provide a way to generate things like <T extends Number & Serializable>.
@tobias- you are right, in that case, an Object replacement of T would not suffice, we would need Number. And in your second example, we could not replace the type parameter at all.
@DayS Yes, as i already confirmed in my first comment, this issue is valid even in the latest snapshot.
If @tobias- is busy i can check this right now, but only if you provide me a binary - i did not setup a building environment for AA (yet). On the other hand, of course i cannot check the original issue with @tobias- ' real code. :)
You didn't need a configured Eclipse to test it but you just have to do a mvn clean install from the PR's branch and use 3.1-SNAPSHOT version in your (sandbox) project, as it'll be installed in your local maven repo :)
Hmm, something is not ok. I just copied the jar from AndroidAnnotations/androidannotations/target folder, and when APT ran, it says NoClassFoundError on EActivity. And the jar is only 374KB, the SNAPSHOT is more than 500.
Also the tests failed when running the functional tests, i guess because of this issue.
AndroidAnnotations/androidannotations contains only AA's core classes.
I think you may want to use the generated zip in AndroidAnnotations/androidannotations-bundle/target
I can also confirm this works with the 858_namedGenerics branch. Multiple bounds are still a problem, but that's expected. Also this very rarely-used Java feature still kills AA: :)
Activity
WonderCsabo commentedon Jan 3, 2014
I can confirm your issue using the latest snapshot.
I think the most easiest way to fix this and all generic-related issues is simply leaving the type parameter in the generated code.
So for this example:
tobias- commentedon Jan 5, 2014
You're right, but doing that removes the type constraint check for the arguments. My actual method has multiple arguments, each typed with
<T>. What I did to solve it was exactly what you suggested, but I had an extra "internal" method that wasn't type safe. Btw, since the@SuprressWarningsannotation isn't copied, AA will produce code with warnings. Not a big issue, but still annoying. It was made extra annoying because the foo method was implementing an interface method.WonderCsabo commentedon Jan 5, 2014
I think my previous comment was not clear. You should not remove the type parameter from your code, because you lost type safety, etc. (Well, i know you have no other option until this is not fixed some way). The generated class by AA should remove the type parameter - in case of the generated class, it does not matter, because types are already checked in your code. By the way some AA code will produce warnings, a discussion started about this in #835.
@DayS, what do you think on my suggestion about generic type?
tobias- commentedon Jan 5, 2014
It will not be easy to implement imho, as if you consider the following (for me common) case:
I.e. you don't get around having to parse the generic type of the method, as the method requires that type for the input.
There are even worse cases like the following, but it should probably be considered rare and could possibly be left for later bug reports.
DayS commentedon Jan 5, 2014
I think it should be easily enough to generate methods with provided generify types by doing only small changes. I already made a PoC and it seems to work fine.
But Codemodel currently doesn't provide a way to generate things like
<T extends Number & Serializable>.DayS commentedon Jan 5, 2014
Ho, about #838, this PR only handled method's params with wildcard. Named generics wasn't handled by this
WonderCsabo commentedon Jan 5, 2014
@tobias- you are right, in that case, an
Objectreplacement ofTwould not suffice, we would needNumber. And in your second example, we could not replace the type parameter at all.@DayS Yes, as i already confirmed in my first comment, this issue is valid even in the latest snapshot.
DayS commentedon Jan 5, 2014
I think this PR should resolve this issue. Could you confirm before I'm merging it ? I would like to release the 3.0.1 hotfix with this.
WonderCsabo commentedon Jan 5, 2014
If @tobias- is busy i can check this right now, but only if you provide me a binary - i did not setup a building environment for AA (yet). On the other hand, of course i cannot check the original issue with @tobias- ' real code. :)
DayS commentedon Jan 5, 2014
You didn't need a configured Eclipse to test it but you just have to do a
mvn clean installfrom the PR's branch and use 3.1-SNAPSHOT version in your (sandbox) project, as it'll be installed in your local maven repo :)WonderCsabo commentedon Jan 5, 2014
Ok, i am on it.
WonderCsabo commentedon Jan 5, 2014
Hmm, something is not ok. I just copied the jar from
AndroidAnnotations/androidannotations/targetfolder, and when APT ran, it saysNoClassFoundErroronEActivity. And the jar is only 374KB, the SNAPSHOT is more than 500.Also the tests failed when running the functional tests, i guess because of this issue.
DayS commentedon Jan 5, 2014
AndroidAnnotations/androidannotationscontains only AA's core classes.I think you may want to use the generated zip in
AndroidAnnotations/androidannotations-bundle/targetWonderCsabo commentedon Jan 5, 2014
Can you send me an email to continue this conversation there? I do not want to further pollute this thread.
tobias- commentedon Jan 6, 2014
Removed previous comment as it works perfect when the test case compiles.
#862 solves it for me, but I would appreciate it if you could add the following test case as well:
WonderCsabo commentedon Jan 6, 2014
I can also confirm this works with the
858_namedGenericsbranch. Multiple bounds are still a problem, but that's expected. Also this very rarely-used Java feature still kills AA: :)DayS commentedon Jan 6, 2014
Great. Thanks for cross testing ;)