diff options
author | Roel Spilker <r.spilker@gmail.com> | 2016-06-28 00:28:52 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2016-06-28 00:28:52 +0200 |
commit | 2a9820d8ec87e0e5e72eff19b56f1bee5f4e37e7 (patch) | |
tree | 23eae646a010f80ee326242e0ae4edfb51abcd32 /src/eclipseAgent/lombok/eclipse/agent | |
parent | ddd4e1feaee9fc4e450c7bed7e7938ff22455756 (diff) | |
download | lombok-2a9820d8ec87e0e5e72eff19b56f1bee5f4e37e7.tar.gz lombok-2a9820d8ec87e0e5e72eff19b56f1bee5f4e37e7.tar.bz2 lombok-2a9820d8ec87e0e5e72eff19b56f1bee5f4e37e7.zip |
[i913] Prevent NPE in PatchDelegate when binding.scope is null
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java index b1f5a43a..e4968f81 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java @@ -699,7 +699,11 @@ public class PatchDelegate { } private static void addAllMethodBindings0(List<BindingTuple> list, TypeBinding binding, Set<String> banList, char[] fieldName, ASTNode responsible) throws DelegateRecursion { - if (binding instanceof SourceTypeBinding) ((SourceTypeBinding) binding).scope.environment().globalOptions.storeAnnotations = true; + if (binding instanceof SourceTypeBinding) { + ClassScope scope = ((SourceTypeBinding) binding).scope; + if (scope == null) return; + scope.environment().globalOptions.storeAnnotations = true; + } if (binding == null) return; TypeBinding inner; @@ -721,42 +725,44 @@ public class PatchDelegate { } } - if (binding instanceof ReferenceBinding) { - ReferenceBinding rb = (ReferenceBinding) binding; - MethodBinding[] availableMethods = rb.availableMethods(); - FieldBinding[] availableFields = rb.availableFields(); - failIfContainsAnnotation(binding, availableMethods); - failIfContainsAnnotation(binding, availableFields); - - MethodBinding[] parameterizedSigs = availableMethods; - MethodBinding[] baseSigs = parameterizedSigs; - if (binding instanceof ParameterizedTypeBinding) { - baseSigs = ((ParameterizedTypeBinding)binding).genericType().availableMethods(); - if (baseSigs.length != parameterizedSigs.length) { - // The last known state of eclipse source says this can't happen, so we rely on it, - // but if this invariant is broken, better to go with 'arg0' naming instead of crashing. - baseSigs = parameterizedSigs; - } - } - for (int i = 0; i < parameterizedSigs.length; i++) { - MethodBinding mb = parameterizedSigs[i]; - String sig = printSig(mb); - if (mb.isStatic()) continue; - if (mb.isBridge()) continue; - if (mb.isConstructor()) continue; - if (mb.isDefaultAbstract()) continue; - if (!mb.isPublic()) continue; - if (mb.isSynthetic()) continue; - if (!banList.add(sig)) continue; // If add returns false, it was already in there. - BindingTuple pair = new BindingTuple(mb, baseSigs[i], fieldName, responsible); - list.add(pair); - } - addAllMethodBindings0(list, rb.superclass(), banList, fieldName, responsible); - ReferenceBinding[] interfaces = rb.superInterfaces(); - if (interfaces != null) { - for (ReferenceBinding iface : interfaces) addAllMethodBindings0(list, iface, banList, fieldName, responsible); + if (!(binding instanceof ReferenceBinding)) { + return; + } + + ReferenceBinding rb = (ReferenceBinding) binding; + MethodBinding[] availableMethods = rb.availableMethods(); + FieldBinding[] availableFields = rb.availableFields(); + failIfContainsAnnotation(binding, availableMethods); + failIfContainsAnnotation(binding, availableFields); + + MethodBinding[] parameterizedSigs = availableMethods; + MethodBinding[] baseSigs = parameterizedSigs; + if (binding instanceof ParameterizedTypeBinding) { + baseSigs = ((ParameterizedTypeBinding)binding).genericType().availableMethods(); + if (baseSigs.length != parameterizedSigs.length) { + // The last known state of eclipse source says this can't happen, so we rely on it, + // but if this invariant is broken, better to go with 'arg0' naming instead of crashing. + baseSigs = parameterizedSigs; } } + for (int i = 0; i < parameterizedSigs.length; i++) { + MethodBinding mb = parameterizedSigs[i]; + String sig = printSig(mb); + if (mb.isStatic()) continue; + if (mb.isBridge()) continue; + if (mb.isConstructor()) continue; + if (mb.isDefaultAbstract()) continue; + if (!mb.isPublic()) continue; + if (mb.isSynthetic()) continue; + if (!banList.add(sig)) continue; // If add returns false, it was already in there. + BindingTuple pair = new BindingTuple(mb, baseSigs[i], fieldName, responsible); + list.add(pair); + } + addAllMethodBindings0(list, rb.superclass(), banList, fieldName, responsible); + ReferenceBinding[] interfaces = rb.superInterfaces(); + if (interfaces != null) { + for (ReferenceBinding iface : interfaces) addAllMethodBindings0(list, iface, banList, fieldName, responsible); + } } private static final char[] STRING_LOMBOK = new char[] {'l', 'o', 'm', 'b', 'o', 'k'}; |