Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

AndroidAnnotations not going through with compilation #390

Closed

Description

@a85

Everything was working fine until it wasn't. Saw the following error:

error: Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.IllegalArgumentException
at com.googlecode.androidannotations.internal.codemodel.JInvocation.arg(JInvocation.java:144)

After repeated attempts it jumped to different parts of the source code for different annoations like @bean and @get.

Activity

  1. pyricau commented on Nov 8, 2012

    @pyricau
    Contributor

    Hello @a85, thank you for reporting this error. Could you please include the full stacktrace ?

  2. a85 commented on Nov 9, 2012

    @a85
    Author

    @pyricau This is what I see in the Messages window in IntelliJ

    Information:Processor com.googlecode.androidannotations.AndroidAnnotationProcessor matches [com.googlecode.androidannotations.annotations.rest.RestService, com.googlecode.androidannotations.annotations.rest.Delete, com.googlecode.androidannotations.annotations.BeforeTextChange, com.googlecode.androidannotations.annotations.AfterTextChange, com.googlecode.androidannotations.annotations.rest.Get, com.googlecode.androidannotations.annotations.UiThread, com.googlecode.androidannotations.annotations.rest.Post, com.googlecode.androidannotations.annotations.EFragment, com.googlecode.androidannotations.annotations.Bean, com.googlecode.androidannotations.annotations.Background, com.googlecode.androidannotations.annotations.rest.Rest, com.googlecode.androidannotations.annotations.EActivity, com.googlecode.androidannotations.annotations.EBean, com.googlecode.androidannotations.annotations.AfterInject, com.googlecode.androidannotations.annotations.rest.Put, com.googlecode.androidannotations.annotations.rest.Accept, com.googlecode.androidannotations.annotations.Click] and returns true.
    Information:Note: Starting AndroidAnnotations annotation processing
    Information:    at com.googlecode.androidannotations.internal.codemodel.JInvocation.arg(JInvocation.java:144)
    Information:    at com.googlecode.androidannotations.processing.rest.MethodProcessor.generateHashMapVar(MethodProcessor.java:133)
    Information:    at com.googlecode.androidannotations.processing.rest.MethodProcessor.generateRestTemplateCallBlock(MethodProcessor.java:92)
    Information:    at com.googlecode.androidannotations.processing.rest.GetProcessor.process(GetProcessor.java:75)
    Information:    at com.googlecode.androidannotations.processing.ModelProcessor.process(ModelProcessor.java:47)
    Information:    at com.googlecode.androidannotations.AndroidAnnotationProcessor.processAnnotations(AndroidAnnotationProcessor.java:472)
    Information:    at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:343)
    Information:    at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:318)
    Information:    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    Information:    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    Information:    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    Information:    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    Information:    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    Information:    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1106)
    Information:    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    Information:    at com.sun.tools.javac.main.Main.compile(Main.java:419)
    Information:    at com.sun.tools.javac.main.Main.compile(Main.java:333)
    Information:    at com.sun.tools.javac.main.Main.compile(Main.java:324)
    Information:    at com.sun.tools.javac.Main.compile(Main.java:76)
    Information:    at com.sun.tools.javac.Main.main(Main.java:61)
    Information:    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Information:    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    Information:    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    Information:    at java.lang.reflect.Method.invoke(Method.java:601)
    Information:    at com.intellij.rt.compiler.JavacRunner.main(JavacRunner.java:71)
    Information:Round 2:
    Information:    input files: {}
    Information:    annotations: []
    Information:    last round: true
    Information:Compilation completed with 13 errors and 31 warnings
    Information:13 errors
    Information:31 warnings
    Error:: Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.IllegalArgumentException
    Warning:: Unclosed files for the types '[dummy1352432799465]'; these types will not undergo annotation processing
    
  3. a85 commented on Nov 9, 2012

    @a85
    Author

    Upgraded to 2.7 but still the same issue. I am trying with creating a new project now.

  4. a85 commented on Nov 9, 2012

    @a85
    Author

    Recompiling again but same error.

    Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.IllegalArgumentException
        at com.sun.codemodel.JInvocation.arg(JInvocation.java:144)
        at com.googlecode.androidannotations.processing.rest.MethodProcessor.generateHashMapVar(MethodProcessor.java:136)
        at com.googlecode.androidannotations.processing.rest.MethodProcessor.generateRestTemplateCallBlock(MethodProcessor.java:94)
        at com.googlecode.androidannotations.processing.rest.GetProcessor.process(GetProcessor.java:77)
        at com.googlecode.androidannotations.processing.ModelProcessor.process(ModelProcessor.java:102)
        at com.googlecode.androidannotations.AndroidAnnotationProcessor.processAnnotations(AndroidAnnotationProcessor.java:505)
        at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:367)
        at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:341)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
        at com.sun.tools.javac.main.Main.compile(Main.java:353)
        at com.sun.tools.javac.main.Main.compile(Main.java:279)
        at com.sun.tools.javac.main.Main.compile(Main.java:270)
        at com.sun.tools.javac.Main.compile(Main.java:69)
        at com.sun.tools.javac.Main.main(Main.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.intellij.rt.compiler.JavacRunner.main(JavacRunner.java:71)
    

    Not sure what exactly is going wrong. I tried

    1. Rebuilt the project
    2. Built the project in Eclipse
    3. Checked out my project from the repo again and set it up as said in the docs
    4. My co-worker's project was working fine but then he started getting the same error. Am wondering if it's a problem with my app code or something else.
  5. pyricau commented on Nov 10, 2012

    @pyricau
    Contributor

    Let's look at this. It's a part of the invoke I haven't been involved a lot so I'm rediscovering it at the same time ( @a-thomas we may need your help here).

    The stacktraces comes from here when calling JInvocation.arg()

    This part of the code is related to having parameters in the URL. So first, could you check all your @Rest interfaces and paste the pieces that contain URL parameters ?

    Here is the content of the JInvocation.arg() method:

        public JInvocation arg(JExpression arg) {
            if(arg==null)   throw new IllegalArgumentException();
            args.add(arg);
            return this;
        }

    The calling code does:

    body.invoke(hashMapVar, "put").arg(urlVariable).arg(methodParams.get(urlVariable));

    So here, either urlVariables contains a null element, or methodParams doesn't contain one of the urlVariable.

    I figured this must have been some matching problem between path parameters and method parameters.

    And I found a way to reproduce the exact same stacktrace:

        @Get("/events/{year}/{year}")
        EventList getEvents(int year);
    

    Do you have any URL in your @Rest interfaces where a parameter name is duplicated?

  6. a85 commented on Nov 10, 2012

    @a85
    Author

    @pyricau Thank you for the reply! That indeed seems to be the case. I just reverted to an older version of the codebase and things started working. Will post the offending piece of code here. Is there a way this can be reported in the stacktrace? Would save a ton of time. The bad part here was that the code did compile for a couple of tries and then started working so could not guess at which point the problem started.

  7. pyricau commented on Nov 11, 2012

    @pyricau
    Contributor

    I definitely agree: this should be reported as a standard error in the right place. This is a bug in AndroidAnnotations.

  8. mathieuboniface commented on Jan 29, 2013

    @mathieuboniface
    Contributor

    Hi folks !

    This one has been fixed !

    No error is thrown, we just allow the user to write an url with a single parameter declared twice.

    Now, with the given code :

        @Get("/events/{year}/{year}")
        @Accept(MediaType.APPLICATION_JSON)
        Event[][] urlWithAParameterDeclaredTwice(int year);

    The following generated is generated :

        @Override
        public Event[][] urlWithAParameterDeclaredTwice(int year) {
            HashMap<String, Object> urlVariables = new HashMap<String, Object>();
            urlVariables.put("year", year);
            HttpHeaders httpHeaders = new HttpHeaders();
            httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType("application/json")));
            HttpEntity<Object> requestEntity = new HttpEntity<Object>(httpHeaders);
            return restTemplate.exchange(rootUrl.concat("/events/{year}/{year}"), HttpMethod.GET, requestEntity, Event[][].class, urlVariables).getBody();
        }
  9. a85 commented on Feb 3, 2013

    @a85
    Author

    Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions