You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Aram Arabyan (JIRA)" <ji...@apache.org> on 2018/06/14 12:11:00 UTC
[jira] [Updated] (GROOVY-8645) ClassCastException after checking of
instanceOf
[ https://issues.apache.org/jira/browse/GROOVY-8645?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Aram Arabyan updated GROOVY-8645:
---------------------------------
Description:
Have grails (version 3.2.11) application (it includes groovy-2.4.11.jar). And following code
{code}
@CompileStatic
def removeAllErrors(DomainClass domainInstance) {
newAssociationOperationRunnerBuilder(domainInstance)
.setSkipChain({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
skipValidation(domainObjectDetails.currentDomain.domainObject, domainObjectDetails.associationProp?.name)})
.build().run({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
DomainClass domain = domainObjectDetails.currentDomain.domainObject
if (domain instanceof GormValidateable) {
((GormValidateable)domain).clearErrors()
}
if(domain instanceof WarningsHolder) {
WarningsHolder warningsHolder = domain as WarningsHolder //<--line 120
Warnings warnings = warningsHolder.getWarnings()
warnings.clearWarnings(false, true)
}
})
}
{code}
And I am getting following exception
{code}
java.lang.IllegalArgumentException: java.lang.ClassCastException@58798bfb
at sun.reflect.GeneratedMethodAccessor5958.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:925)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.asType(ScriptBytecodeAdapter.java:591)
at com.webbfontaine.grails.plugins.validation.rules.DocVerificationService$_removeAllErrors_closure5.doCall(DocVerificationService.groovy:120)
at sun.reflect.GeneratedMethodAccessor2559.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325){code}
Any idea what can be the reason ? Pay attention that I have @CompileStatic there also.
========================================================================= Previous version of this code was without @CompileStatic
{code}
def removeAllErrors(def domainInstance) {
newAssociationOperationRunnerBuilder(domainInstance)
.setSkipChain({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
skipValidation(domainObjectDetails.currentDomain.domainObject, domainObjectDetails.associationProp?.name)})
.build().run({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
domainObjectDetails.currentDomain.domainObject.clearErrors()
if(domainObjectDetails.currentDomain.domainObject instanceof WarningsHolder) {
Warnings warnings = domainObjectDetails.currentDomain.domainObject.getWarnings()
warnings.clearWarnings(false, true)
}
})
}
{code}
And I was getting this exception
{code}
{{com.webbfontaine.sw.sad.ci.Item cannot be cast to com.webbfontaine.sw.sad.ci.Item_$$_jvst840_3. Stacktrace follows: java.lang.ClassCastException: com.webbfontaine.sw.sad.ci.Item cannot be cast to com.webbfontaine.sw.sad.ci.Item_$$_jvst840_3 at com.webbfontaine.grails.plugins.validation.rules.DocVerificationService$_removeAllErrors_closure5.doCall(DocVerificationService.groovy:111)\{code}}}
was:
Have grails (version 3.2.11) application (it includes groovy-2.4.11.jar). And following code
{code}
{{ @CompileStatic def removeAllErrors(DomainClass domainInstance) { newAssociationOperationRunnerBuilder(domainInstance) .setSkipChain({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails -> skipValidation(domainObjectDetails.currentDomain.domainObject, domainObjectDetails.associationProp?.name)}) .build().run({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails -> DomainClass domain = domainObjectDetails.currentDomain.domainObject if (domain instanceof GormValidateable) { ((GormValidateable)domain).clearErrors() } if(domain instanceof WarningsHolder) { WarningsHolder warningsHolder = domain as WarningsHolder //<--- line 120 Warnings warnings = warningsHolder.getWarnings() warnings.clearWarnings(false, true) } }) }}}
{code}
And I am getting following exception
{code}
{{}}
{{2018-06-14 10:16:41,647 ERROR StackTrace - Full Stack Trace: java.lang.IllegalArgumentException: java.lang.ClassCastException@3f6e3869 at sun.reflect.GeneratedMethodAccessor5958.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:925) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.asType(ScriptBytecodeAdapter.java:591) at com.webbfontaine.grails.plugins.validation.rules.DocVerificationService$_removeAllErrors_closure5.doCall(DocVerificationService.groovy:120)}}
{code}
Any idea what can be the reason ? Pay attention that I have @CompileStatic there also.
========================================================================= Previous version of this code was without @CompileStatic
{code}
{{ def removeAllErrors(def domainInstance) { newAssociationOperationRunnerBuilder(domainInstance) .setSkipChain({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails -> skipValidation(domainObjectDetails.currentDomain.domainObject, domainObjectDetails.associationProp?.name)}) .build().run({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails -> domainObjectDetails.currentDomain.domainObject.clearErrors() if(domainObjectDetails.currentDomain.domainObject instanceof WarningsHolder) { Warnings warnings = domainObjectDetails.currentDomain.domainObject.getWarnings() warnings.clearWarnings(false, true) } }) }}}
{code}
And I was getting this exception
{code}
{{com.webbfontaine.sw.sad.ci.Item cannot be cast to com.webbfontaine.sw.sad.ci.Item_$$_jvst840_3. Stacktrace follows: java.lang.ClassCastException: com.webbfontaine.sw.sad.ci.Item cannot be cast to com.webbfontaine.sw.sad.ci.Item_$$_jvst840_3 at com.webbfontaine.grails.plugins.validation.rules.DocVerificationService$_removeAllErrors_closure5.doCall(DocVerificationService.groovy:111)\{code}}}
> ClassCastException after checking of instanceOf
> -----------------------------------------------
>
> Key: GROOVY-8645
> URL: https://issues.apache.org/jira/browse/GROOVY-8645
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 2.4.11
> Reporter: Aram Arabyan
> Priority: Minor
>
> Have grails (version 3.2.11) application (it includes groovy-2.4.11.jar). And following code
> {code}
> @CompileStatic
> def removeAllErrors(DomainClass domainInstance) {
> newAssociationOperationRunnerBuilder(domainInstance)
> .setSkipChain({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
> skipValidation(domainObjectDetails.currentDomain.domainObject, domainObjectDetails.associationProp?.name)})
> .build().run({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
> DomainClass domain = domainObjectDetails.currentDomain.domainObject
> if (domain instanceof GormValidateable) {
> ((GormValidateable)domain).clearErrors()
> }
> if(domain instanceof WarningsHolder) {
> WarningsHolder warningsHolder = domain as WarningsHolder //<--line 120
> Warnings warnings = warningsHolder.getWarnings()
> warnings.clearWarnings(false, true)
> }
> })
> }
> {code}
> And I am getting following exception
> {code}
> java.lang.IllegalArgumentException: java.lang.ClassCastException@58798bfb
> at sun.reflect.GeneratedMethodAccessor5958.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
> at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
> at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:925)
> at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.asType(ScriptBytecodeAdapter.java:591)
> at com.webbfontaine.grails.plugins.validation.rules.DocVerificationService$_removeAllErrors_closure5.doCall(DocVerificationService.groovy:120)
> at sun.reflect.GeneratedMethodAccessor2559.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325){code}
> Any idea what can be the reason ? Pay attention that I have @CompileStatic there also.
> ========================================================================= Previous version of this code was without @CompileStatic
> {code}
> def removeAllErrors(def domainInstance) {
> newAssociationOperationRunnerBuilder(domainInstance)
> .setSkipChain({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
> skipValidation(domainObjectDetails.currentDomain.domainObject, domainObjectDetails.associationProp?.name)})
> .build().run({DomainObjectDetails<DomainObjectDataSingle> domainObjectDetails ->
> domainObjectDetails.currentDomain.domainObject.clearErrors()
> if(domainObjectDetails.currentDomain.domainObject instanceof WarningsHolder) {
> Warnings warnings = domainObjectDetails.currentDomain.domainObject.getWarnings()
> warnings.clearWarnings(false, true)
> }
> })
> }
> {code}
> And I was getting this exception
> {code}
> {{com.webbfontaine.sw.sad.ci.Item cannot be cast to com.webbfontaine.sw.sad.ci.Item_$$_jvst840_3. Stacktrace follows: java.lang.ClassCastException: com.webbfontaine.sw.sad.ci.Item cannot be cast to com.webbfontaine.sw.sad.ci.Item_$$_jvst840_3 at com.webbfontaine.grails.plugins.validation.rules.DocVerificationService$_removeAllErrors_closure5.doCall(DocVerificationService.groovy:111)\{code}}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)