You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Huan Tu Tat (JIRA)" <ji...@apache.org> on 2019/04/16 17:15:00 UTC

[jira] [Created] (GROOVY-9088) Groovy with @Compilestatic problem

Huan Tu Tat created GROOVY-9088:
-----------------------------------

             Summary: Groovy with @Compilestatic problem
                 Key: GROOVY-9088
                 URL: https://issues.apache.org/jira/browse/GROOVY-9088
             Project: Groovy
          Issue Type: Bug
          Components: Compiler, Static compilation
    Affects Versions: 2.4.15
            Reporter: Huan Tu Tat


When I compile to class, Groovy pass my *RetryPolicy* to *Failsafe*.*with*(Policy... policies) function as *Object*[]. However, I expect that Groovy will pass it as *RetryPolicy*[] instead of *Object*[].

When it's *Object*[], my application will be wrong because I need to pass a *Policy*[] in to this function.

(I'm using Failsafe lib [in here|[https://github.com/jhalterman/failsafe])

My code:

 
{code:java}
final RetryPolicy<Object> RETRY_POLICY = new RetryPolicy<>()
 .withDelay(Duration.ofSeconds(5))
 .withMaxRetries(60)
 .onFailedAttempt({ error -> log.warn("@An error must be retried:", error.getLastFailure()) })
 .onRetry({ error -> log.info("@Failure #{}. Retrying...", error.getAttemptCount()) })
Failsafe.with(RETRY_POLICY){code}
 

Complicated code .class file:

 
{code:java}
Failsafe.with(new Object[]{RETRY_POLICY});{code}
 

Complicated code .class file when I don't use @CompileStatic

 
{code:java}
RetryPolicy RETRY_POLICY = (RetryPolicy)ScriptBytecodeAdapter.castToType(var2[9].call(var2[10].call(var2[11].call(var2[12].call(var2[13].callConstructor(RetryPolicy.class), var2[14].call(Duration.class, 5)), 60), new _fillWebsiteInfo_closure1(this, this)), new _fillWebsiteInfo_closure2(this, this)), RetryPolicy.class);
var2[15].call(Failsafe.class, RETRY_POLICY);{code}
 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)