You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2023/03/13 22:19:58 UTC
[groovy] branch GROOVY_2_5_X updated: fix for NPE
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
new 0bdb662b72 fix for NPE
0bdb662b72 is described below
commit 0bdb662b727de5707df94a51e198aab2d08a6180
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Mar 13 17:19:48 2023 -0500
fix for NPE
---
.../org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
index 445ed0a82b..ee77db0d0c 100644
--- a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
@@ -52,7 +52,7 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper impleme
private final SourceUnit sourceUnit;
private ClassNode classNode;
- private FieldNode thisField = null;
+ private FieldNode thisField;
private static final String
CLOSURE_INTERNAL_NAME = BytecodeHelper.getClassInternalName(ClassHelper.CLOSURE_TYPE),
@@ -71,8 +71,9 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper impleme
public void visitClass(ClassNode node) {
classNode = node;
thisField = null;
+ if (node.isEnum() || node.isInterface()) return;
InnerClassNode innerClass = null;
- if (!node.isEnum() && !node.isInterface() && node instanceof InnerClassNode) {
+ if (node instanceof InnerClassNode) {
innerClass = (InnerClassNode) node;
thisField = innerClass.getField("this$0");
if (innerClass.getVariableScope() == null && innerClass.getDeclaredConstructors().isEmpty()) {
@@ -80,7 +81,6 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper impleme
addGeneratedConstructor(innerClass, ACC_PUBLIC, Parameter.EMPTY_ARRAY, null, null);
}
}
- if (node.isEnum() || node.isInterface()) return;
// use Iterator.hasNext() to check for available inner classes
if (node.getInnerClasses().hasNext()) addDispatcherMethods(node);
if (innerClass == null) return;
@@ -419,7 +419,7 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper impleme
block = (BlockStatement) code;
}
BlockStatement newCode = new BlockStatement();
- addFieldInit(thisPara, thisField, newCode);
+ if (thisField != null) addFieldInit(thisPara, thisField, newCode);
ConstructorCallExpression cce = getFirstIfSpecialConstructorCall(block);
if (cce == null) {
cce = new ConstructorCallExpression(ClassNode.SUPER, new TupleExpression());