mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 08:15:48 +00:00
[i913] Prevent NPE in PatchDelegate when binding.scope is null
This commit is contained in:
1 parent
ddd4e1feae
commit
2a9820d8ec
2 files changed
+42
-36
No files matched your search
@@ -4,9 +4,9 @@ Lombok Changelog
|
||||
### v1.16.9 "Edgy Guinea Pig"
|
||||
* FEATURE: Added support for JBoss logger [Issue #1103](https://github.com/rzwitserloot/lombok/issues/1103)
|
||||
* ENHANCEMENT: Running `javac -Xlint:all` would generate a warning about unclaimed annotations [Issue #1117](https://github.com/rzwitserloot/lombok/issues/1117)
|
||||
* BUGFIX: Eclipse Mars would sometimes throw a NullPointerException when using `@Delegate` [Issue 913](https://github.com/rzwitserloot/lombok/issues/913)
|
||||
|
||||
### v1.16.8 (March 7th, 2016)
|
||||
|
||||
* PLATFORM: Starting jdk9 support: No more error message regarding `pid`
|
||||
* FEATURE: `@Builder` updates: It now generates `clearFieldName()` methods if `@Singular` is used. [Issue #967](https://github.com/rzwitserloot/lombok/issues/967).
|
||||
* FEATURE: `@Builder` updates: The annotation can now be put on instance methods. [Issue #63](https://github.com/rzwitserloot/lombok/issues/63).
|
||||
|
||||
@@ -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'};
|
||||
|
||||
Reference in new issue
Block a user