Skip to content

Commit

Permalink
ExceptionHandlingFlowContext: use java.util.IdentityHashMap
Browse files Browse the repository at this point in the history
* avoids raw types
* deletes custom ObjectCache

ObjectCache implemented a HashMap using hashCode() but not equals().
Instead it used == identity. JDK offers a special Map for identity since
1.4, consistently using System.identityHashCode().

relates to eclipse-jdt#3412
  • Loading branch information
EcljpseB0T committed Dec 9, 2024
1 parent d37105b commit 110945d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 167 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.IdentityHashMap;
import java.util.List;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
Expand All @@ -28,7 +29,6 @@
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
import org.eclipse.jdt.internal.compiler.codegen.ObjectCache;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.CatchParameterBinding;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
Expand All @@ -42,7 +42,6 @@
* Reflects the context of code analysis, keeping track of enclosing
* try statements, exception handlers, etc...
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class ExceptionHandlingFlowContext extends FlowContext {

public final static int BitCacheSize = 32; // 32 bits per int
Expand All @@ -52,14 +51,14 @@ public class ExceptionHandlingFlowContext extends FlowContext {
int[] isNeeded;
// WARNING: This is an array that maps to catch blocks, not caught exceptions (which could be more than catch blocks in a multi-catch block)
UnconditionalFlowInfo[] initsOnExceptions;
ObjectCache indexes = new ObjectCache();
IdentityHashMap<ReferenceBinding, Integer> indexes = new IdentityHashMap<>();
boolean isMethodContext;

public UnconditionalFlowInfo initsOnReturn;
public FlowContext initializationParent; // special parent relationship only for initialization purpose

// for dealing with anonymous constructor thrown exceptions
public List extendedExceptions;
public List<TypeBinding> extendedExceptions;

private static final Argument[] NO_ARGUMENTS = new Argument[0];
public Argument [] catchArguments;
Expand Down Expand Up @@ -255,7 +254,7 @@ public void mergeUnhandledException(TypeBinding newException){
boolean isRedundant = false;

for(int i = this.extendedExceptions.size()-1; i >= 0; i--){
switch(Scope.compareTypes(newException, (TypeBinding)this.extendedExceptions.get(i))){
switch(Scope.compareTypes(newException, this.extendedExceptions.get(i))){
case Scope.MORE_GENERIC :
this.extendedExceptions.remove(i);
break;
Expand Down

0 comments on commit 110945d

Please sign in to comment.