Repository navigation
@Bean doesn't work with parameterized class #103
Description
Activity
It's more than just this warning. The generated subclass should be parameterized too, and getInstance should return a covariant result.
- added a commit that references this issue
on Apr 13, 2013 This still does not work unfortunately.
The generated import:
import com.example.Pojo<java.lang.String>_;
The generated injection:
a = String>_.getInstance_(this);
@DayS, can you check @Artyomcool's PR someday?
I'm on it right now. I started 3.0.1 release.. But I'll revert it. This should be fixed before
The problem described in my comment is still here. :S
Sorry for asking, but are you sure?
There is exactly such test case and it's ok.
Could you double check?If it is, could you provide full source code?
Of course.
@EBean public class GenericBean<T> { }
@EActivity public class MainActivity extends Activity { @Bean GenericBean<String> bean; }
Generated code:
private void init_(Bundle savedInstanceState) { bean = GenericBean<T>_.getInstance_(this); }
Project is available here.
Yep, just confirmed.. Fu** >_<
By the way, generated getInstance method should look like this :
public static <T> GenericBean_<T> getInstance_(Context context) { return new GenericBean_<T>(context); }
instead of
public static GenericBean_ getInstance_(Context context) { return new GenericBean_(context); }
It's optional but it may be cleaner :) (Unless this is too much work and complexity in code)
I just read your comments about Eclipse internal builder, so i checked this case with maven - it builds successfully. @Artyomcool was right, there is a compile-time test for this.
Not much. I'll do my bests to fix it tomorrow.
13.01.2014 23:01 ÐÏÌØÚÏ×ÁÔÅÌØ "Damien" notifications@github.com ÎÁÐÉÓÁÌ:Yep, just confirmed.. Fu** >_<
By the way, generated getInstance method should look like this :
public static GenericBean_ getInstance_(Context context) {
return new GenericBean_(context);}instead of
public static GenericBean_ getInstance_(Context context) {
return new GenericBean_(context);}It's optional but it may be cleaner :) (Unless this is too much work and
complexity in code)Reply to this email directly or view it on GitHubhttps://github.com//issues/103#issuecomment-32199408
.Looks like I need to install eclipse :)
There is an option in the
m2e-aptplugin - which is in the wiki for using AA, but not in the contribution page (why?) - to use the normal APT and not the Eclipse internal JDT APT. To use this option, the POM should be changed to configure correctly themaven-processor-plugin. Unfortunately, i was not able to do so, the problem was that APT did not found theRclass. May be you guys can try it out. This could solve all the problems with the Eclipse internal builder, but only for Maven users.@DayS, looks the only way it can be fixed - if eclipse can't give me erasure - parse the class name manually:
In BeanHandler:elementType = holder.processingEnvironment().getTypeUtils().erasure(elementType);My best gues - eclipse know nothing about
elementType(because build is incrimental), so it is presented just as a direct declaration and erasure can't do the job. What do you think? Should I parse it manually?This could solve all the problems with the Eclipse internal builder, but only for Maven users.
Gradle always uses normal APT (AFAIK), so not only for Maven, but for gradle too.
What is the status of this issue? Should this be closed?
Annotate a parameterized class result in a wrong generated code:
The following is generated: