mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 08:34:25 +02:00
Remove the ExceptionHandler template parameter from ClassSection
In DexBuilder, instead of statically specifying a specific ExceptionHandler type, we dynamically check that the exception type reference returned from the ExceptionHandler is of the proper type
This commit is contained in:
parent
9bbcaae91f
commit
6f135aeb74
@ -31,6 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.writer;
|
||||
|
||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
|
||||
@ -42,8 +43,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ClassSection<StringKey extends CharSequence, TypeKey extends CharSequence, TypeListKey, ClassKey,
|
||||
FieldKey, MethodKey, AnnotationSetKey, EncodedValue, Insn,
|
||||
ExceptionHandler extends org.jf.dexlib2.iface.ExceptionHandler> extends IndexSection<ClassKey> {
|
||||
FieldKey, MethodKey, AnnotationSetKey, EncodedValue, Insn> extends IndexSection<ClassKey> {
|
||||
@Nonnull Collection<? extends ClassKey> getSortedClasses();
|
||||
|
||||
@Nullable Map.Entry<? extends ClassKey, Integer> getClassEntryByType(@Nullable TypeKey key);
|
||||
|
@ -39,6 +39,7 @@ import org.jf.dexlib2.AccessFlags;
|
||||
import org.jf.dexlib2.base.BaseAnnotation;
|
||||
import org.jf.dexlib2.dexbacked.raw.*;
|
||||
import org.jf.dexlib2.iface.Annotation;
|
||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.debug.LineNumber;
|
||||
@ -76,7 +77,7 @@ public abstract class DexWriter<
|
||||
TypeListKey,
|
||||
FieldKey, MethodKey,
|
||||
EncodedValue, AnnotationElement,
|
||||
Insn extends Instruction, ExceptionHandler extends org.jf.dexlib2.iface.ExceptionHandler> {
|
||||
Insn extends Instruction> {
|
||||
public static final int NO_INDEX = -1;
|
||||
public static final int NO_OFFSET = 0;
|
||||
|
||||
@ -116,7 +117,7 @@ public abstract class DexWriter<
|
||||
protected final FieldSection<StringKey, TypeKey, FieldRefKey, FieldKey> fieldSection;
|
||||
protected final MethodSection<StringKey, TypeKey, ProtoKey, MethodRefKey, MethodKey> methodSection;
|
||||
protected final ClassSection<StringKey, TypeKey, TypeListKey, ClassKey, FieldKey, MethodKey, AnnotationSetKey,
|
||||
EncodedValue, Insn, ExceptionHandler> classSection;
|
||||
EncodedValue, Insn> classSection;
|
||||
|
||||
protected final TypeListSection<TypeKey, TypeListKey> typeListSection;
|
||||
protected final AnnotationSection<StringKey, TypeKey, AnnotationKey, AnnotationElement, EncodedValue> annotationSection;
|
||||
@ -130,7 +131,7 @@ public abstract class DexWriter<
|
||||
FieldSection<StringKey, TypeKey, FieldRefKey, FieldKey> fieldSection,
|
||||
MethodSection<StringKey, TypeKey, ProtoKey, MethodRefKey, MethodKey> methodSection,
|
||||
ClassSection<StringKey, TypeKey, TypeListKey, ClassKey, FieldKey, MethodKey, AnnotationSetKey,
|
||||
EncodedValue, Insn, ExceptionHandler> classSection,
|
||||
EncodedValue, Insn> classSection,
|
||||
TypeListSection<TypeKey, TypeListKey> typeListSection,
|
||||
AnnotationSection<StringKey, TypeKey, AnnotationKey, AnnotationElement,
|
||||
EncodedValue> annotationSection,
|
||||
|
@ -35,6 +35,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.*;
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||
import org.jf.dexlib2.iface.Field;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
import org.jf.dexlib2.iface.debug.*;
|
||||
@ -57,8 +58,7 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class BuilderClassPool implements ClassSection<BuilderStringReference, BuilderTypeReference, BuilderTypeList,
|
||||
BuilderClassDef, BuilderField, BuilderMethod, BuilderAnnotationSet, BuilderEncodedValue, BuilderInstruction,
|
||||
BuilderExceptionHandler> {
|
||||
BuilderClassDef, BuilderField, BuilderMethod, BuilderAnnotationSet, BuilderEncodedValue, BuilderInstruction> {
|
||||
@Nonnull private final ConcurrentMap<String, BuilderClassDef> internedItems =
|
||||
Maps.newConcurrentMap();
|
||||
|
||||
@ -307,8 +307,8 @@ public class BuilderClassPool implements ClassSection<BuilderStringReference, Bu
|
||||
return impl.getTryBlocks();
|
||||
}
|
||||
|
||||
@Nullable @Override public BuilderTypeReference getExceptionType(@Nonnull BuilderExceptionHandler handler) {
|
||||
return handler.exceptionType;
|
||||
@Nullable @Override public BuilderTypeReference getExceptionType(@Nonnull ExceptionHandler handler) {
|
||||
return checkTypeReference(handler.getExceptionTypeReference());
|
||||
}
|
||||
|
||||
@Override public void setEncodedArrayOffset(@Nonnull BuilderClassDef builderClassDef, int offset) {
|
||||
|
@ -56,7 +56,7 @@ import java.util.Set;
|
||||
public class DexBuilder extends DexWriter<BuilderStringReference, BuilderStringReference, BuilderTypeReference,
|
||||
BuilderTypeReference, BuilderProtoReference, BuilderFieldReference, BuilderMethodReference, BuilderReference,
|
||||
BuilderClassDef, BuilderAnnotation, BuilderAnnotationSet, BuilderTypeList, BuilderField, BuilderMethod,
|
||||
BuilderEncodedValue, BuilderAnnotationElement, BuilderInstruction, BuilderExceptionHandler> {
|
||||
BuilderEncodedValue, BuilderAnnotationElement, BuilderInstruction> {
|
||||
|
||||
private final BuilderContext context;
|
||||
|
||||
|
@ -60,7 +60,7 @@ import java.util.Map.Entry;
|
||||
public class ClassPool implements ClassSection<CharSequence, CharSequence,
|
||||
TypeListPool.Key<? extends Collection<? extends CharSequence>>, PoolClassDef, Field, PoolMethod,
|
||||
Set<? extends Annotation>,
|
||||
EncodedValue, Instruction, ExceptionHandler> {
|
||||
EncodedValue, Instruction> {
|
||||
@Nonnull private HashMap<String, PoolClassDef> internedItems = Maps.newHashMap();
|
||||
|
||||
@Nonnull private final StringPool stringPool;
|
||||
|
@ -50,7 +50,7 @@ public class DexPool extends DexWriter<CharSequence, StringReference, CharSequen
|
||||
FieldReference, MethodReference, Reference, PoolClassDef,
|
||||
Annotation, Set<? extends Annotation>,
|
||||
TypeListPool.Key<? extends Collection<? extends CharSequence>>, Field, PoolMethod,
|
||||
EncodedValue, AnnotationElement, Instruction, ExceptionHandler> {
|
||||
EncodedValue, AnnotationElement, Instruction> {
|
||||
|
||||
public static DexPool makeDexPool() {
|
||||
return makeDexPool(15);
|
||||
|
Loading…
x
Reference in New Issue
Block a user