ouzhiyin / androidannotations

Automatically exported from code.google.com/p/androidannotations
0 stars 0 forks source link

Using @Extra without value adds an additional unexpected compile error #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Given the following code :

@EActivity
public class ExtraInjectedActivity extends Activity{

    @Extra
    String simpleExtra;

}

Obviously, @Extra lacks a "key" value. A compile error is shown on @Extra, but 
another unexpected error happens, appearing on simpleExtra :

Unexpected error. Please report an issue on AndroidAnnotations, with the 
following content: java.lang.NullPointerExceptionat 
com.googlecode.androidannotations.internal.codemodel.JExpr.quotify(JExpr.java:23
9)
at 
com.googlecode.androidannotations.internal.codemodel.JStringLiteral.generate(JSt
ringLiteral.java:61)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.g(JFormatter.jav
a:350)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.g(JFormatter.jav
a:363)
at 
com.googlecode.androidannotations.internal.codemodel.JInvocation.generate(JInvoc
ation.java:185)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.g(JFormatter.jav
a:350)
at 
com.googlecode.androidannotations.internal.codemodel.JConditional.state(JConditi
onal.java:113)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.s(JFormatter.jav
a:386)
at 
com.googlecode.androidannotations.internal.codemodel.JBlock.generateBody(JBlock.
java:448)
at 
com.googlecode.androidannotations.internal.codemodel.JBlock.generate(JBlock.java
:436)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.g(JFormatter.jav
a:350)
at 
com.googlecode.androidannotations.internal.codemodel.JConditional.state(JConditi
onal.java:115)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.s(JFormatter.jav
a:386)
at 
com.googlecode.androidannotations.internal.codemodel.JBlock.generateBody(JBlock.
java:448)
at 
com.googlecode.androidannotations.internal.codemodel.JBlock.generate(JBlock.java
:436)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.g(JFormatter.jav
a:350)
at 
com.googlecode.androidannotations.internal.codemodel.JBlock.state(JBlock.java:46
4)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.s(JFormatter.jav
a:386)
at 
com.googlecode.androidannotations.internal.codemodel.JMethod.declare(JMethod.jav
a:460)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.d(JFormatter.jav
a:376)
at 
com.googlecode.androidannotations.internal.codemodel.JDefinedClass.declareBody(J
DefinedClass.java:816)
at 
com.googlecode.androidannotations.internal.codemodel.JDefinedClass.declare(JDefi
nedClass.java:789)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.d(JFormatter.jav
a:376)
at 
com.googlecode.androidannotations.internal.codemodel.JFormatter.write(JFormatter
.java:406)
at 
com.googlecode.androidannotations.internal.codemodel.JPackage.build(JPackage.jav
a:438)
at 
com.googlecode.androidannotations.internal.codemodel.JCodeModel.build(JCodeModel
.java:311)
at 
com.googlecode.androidannotations.generation.CodeModelGenerator.generate(CodeMod
elGenerator.java:42)
at 
com.googlecode.androidannotations.AndroidAnnotationProcessor.generateSources(And
roidAnnotationProcessor.java:325)
at 
com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(And
roidAnnotationProcessor.java:220)
at 
com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnno
tationProcessor.java:193)
at 
org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(R
oundDispatcher.java:139)
at 
org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispat
cher.java:121)
at 
org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.pr
ocessAnnotations(BaseAnnotationProcessorManager.java:159)
at 
org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManag
er.processAnnotations(IdeAnnotationProcessorManager.java:134)
at 
org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:809)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
at 
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImage
Builder.java:364)
at 
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(Incrementa
lImageBuilder.java:321)
at 
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImage
Builder.java:301)
at 
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalI
mageBuilder.java:134)
at 
org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:2
65)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at 
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
at 
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at 
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
at 
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:3
11)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Original issue reported on code.google.com by py.ricau on 18 Jul 2011 at 1:44

GoogleCodeExporter commented 9 years ago
That's weird, because an @Extra annotation without any value is invalid and 
shouldn't even be given to the AnnotationProcessor. Here is the @Extra 
definition:

@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.FIELD)
public @interface Extra {
    String value();
}

Original comment by py.ricau on 18 Jul 2011 at 2:12

GoogleCodeExporter commented 9 years ago
There also seems to be a CodeModel related bug here, it should have failed 
earlier, instead of going all NPE..

Original comment by py.ricau on 18 Jul 2011 at 2:15

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1110.

Original comment by py.ricau on 18 Jul 2011 at 2:34