[
https://issues.apache.org/jira/browse/GROOVY-7883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15514452#comment-15514452
]
Juan MartÃn Sotuyo Dodero edited comment on GROOVY-7883 at 9/22/16 8:55 PM:
----------------------------------------------------------------------------
I'm seeing the exact same problem. new AssertionError("any string") is valid
java code calling AssertionError(java.lang.Object). Groovy with @CompileStatic
fails due to private constructor AssertionError(java.lang.String).
As a workaround in the meantime, writing new AssertionError('any string' as
Object) gets the static compiler to actually compile the code.
was (Author: jmsotuyo):
I'm seeing the exact same problem. new AssertionError("any string") is valid
java code calling AssertionError(java.lang.Object). Groovy with @CompileStatic
fails due to private constructor AssertionError(java.lang.String).
> Static compiler prefers private constructor over public if private matches
> better
> ---------------------------------------------------------------------------------
>
> Key: GROOVY-7883
> URL: https://issues.apache.org/jira/browse/GROOVY-7883
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.4.7
> Reporter: Jason Winnebeck
>
> When constructing an AssertionError for example, it has a public constructor
> taking Object and a private constructor taking String. The static compiler
> "chooses" the private constructor over the public one and this results in a
> compile error.
> {code}
> @groovy.transform.CompileStatic
> void doIt() {
> //Cannot call private constructor for java.lang.AssertionError. However, it
> should call AssertionError(Object)
> throw new AssertionError("abc")
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)