You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/02/15 14:56:00 UTC
[jira] [Commented] (GROOVY-10935) MissingPropertyException truncates nested class name
[ https://issues.apache.org/jira/browse/GROOVY-10935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17689177#comment-17689177 ]
Eric Milles commented on GROOVY-10935:
--------------------------------------
{code}
groovy.lang.MissingPropertyException: No such property: missing for class: Outer
at Outer$Inner.propertyMissing(Scratch.groovy)
{code}
The inner class has a synthetic {{propertyMissing}} method that tries the outer class. This would need to catch MissingPropertyException and produce one for the inner class (or modify the message of the outer's exception).
{code:java}
addSyntheticMethod(node,
"propertyMissing",
ACC_PUBLIC,
OBJECT_TYPE,
params(param(STRING_TYPE, "name")),
(methodBody, parameters) -> {
if (isStatic) {
setPropertyGetterDispatcher(methodBody, classX(outerClass), parameters);
} else {
methodBody.addStatement(
new BytecodeSequence(new BytecodeInstruction() {
@Override
public void visit(final MethodVisitor mv) {
getThis(mv, classInternalName, outerClassDescriptor, outerClassInternalName);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, outerClassInternalName, "this$dist$get$" + outerClassDistance, "(Ljava/lang/String;)Ljava/lang/Object;", false);
mv.visitInsn(ARETURN);
}
})
);
}
}
);
{code}
> MissingPropertyException truncates nested class name
> ----------------------------------------------------
>
> Key: GROOVY-10935
> URL: https://issues.apache.org/jira/browse/GROOVY-10935
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.9
> Reporter: Christopher Smith
> Priority: Minor
>
> When a nested class is the target of an invalid property expression, the resulting error message has the wrong class name:
> {code:groovy}
> class Outer {
> static class Inner {}
> }
> new Outer.Inner().missing
> {code}
> results in
> {code}
> groovy.lang.MissingPropertyException: No such property: missing for class: com.example.Outer
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)