Skip to content

Commit

Permalink
Fixes eclipse-jdt#3213 - NPE and stack overflow protection
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <stryker@redhat.com>
  • Loading branch information
Rob Stryker committed Nov 1, 2024
1 parent e25332f commit 6b6aa0d
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,9 @@ public RecordComponentBinding getComponent(char[] componentName, boolean needRes
// NOTE: the return type, arg & exception types of each method of a source type are resolved when needed
@Override
public MethodBinding[] getMethods(char[] selector) {
return getMethods(selector, true);
}
public MethodBinding[] getMethods(char[] selector, boolean shouldTryAgain) {
if (!isPrototype())
return this.prototype.getMethods(selector);

Expand Down Expand Up @@ -1740,8 +1743,11 @@ public MethodBinding[] getMethods(char[] selector) {
for (int i = start; i <= end; i++) {
MethodBinding method = this.methods[i];
if (resolveTypesFor(method) == null || method.returnType == null) {
methods();
return getMethods(selector); // try again since the problem methods have been removed
if( shouldTryAgain ) {
methods();
return getMethods(selector, false); // try again since the problem methods have been removed
}
return new MethodBinding[0];
}
}
int length = end - start + 1;
Expand All @@ -1757,8 +1763,11 @@ public MethodBinding[] getMethods(char[] selector) {
? method.areParameterErasuresEqual(result[j])
: method.areParametersEqual(result[j]);
if (paramsMatch) {
methods();
return getMethods(selector); // try again since the duplicate methods have been removed
if( shouldTryAgain ) {
methods();
return getMethods(selector); // try again since the duplicate methods have been removed
}
return new MethodBinding[0];
}
}
}
Expand Down Expand Up @@ -2069,6 +2078,9 @@ private int getImplicitMethod(MethodBinding[] resolvedMethods, char[] name) {
// NOTE: the return type, arg & exception types of each method of a source type are resolved when needed
@Override
public MethodBinding[] methods() {
if( this.scope == null ) {
return new MethodBinding[0];
}

components(); // In a record declaration, the components should be complete prior to fields and probably for methods

Expand Down Expand Up @@ -2543,6 +2555,10 @@ public FieldBinding resolveTypeFor(FieldBinding field) {
}

public MethodBinding resolveTypesFor(MethodBinding method) {
if( scope == null ) {
return null;
}

ProblemReporter problemReporter = this.scope.problemReporter();
try {
IErrorHandlingPolicy suspendedPolicy = problemReporter.suspendTempErrorHandlingPolicy();
Expand Down

0 comments on commit 6b6aa0d

Please sign in to comment.