mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 04:27:38 +02:00
ExceptionHandlers are now stored in a List rather than a Set. Order matters.
This commit is contained in:

committed by
Ben Gruver

parent
03411559cf
commit
56c7adde03
@ -31,12 +31,12 @@
|
||||
|
||||
package org.jf.dexlib2.dexbacked;
|
||||
|
||||
import org.jf.dexlib2.dexbacked.util.VariableSizeSet;
|
||||
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
|
||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
public class DexBackedTryBlock implements TryBlock {
|
||||
@Nonnull public final DexBuffer dexBuf;
|
||||
@ -60,24 +60,24 @@ public class DexBackedTryBlock implements TryBlock {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<? extends ExceptionHandler> getExceptionHandlers() {
|
||||
public List<? extends ExceptionHandler> getExceptionHandlers() {
|
||||
DexReader reader =
|
||||
dexBuf.readerAt(handlersStartOffset + dexBuf.readUshort(tryItemOffset + HANDLER_OFFSET_OFFSET));
|
||||
final int encodedSize = reader.readSleb128();
|
||||
|
||||
if (encodedSize > 0) {
|
||||
//no catch-all
|
||||
return new VariableSizeSet<ExceptionHandler>(dexBuf, reader.getOffset(), encodedSize) {
|
||||
return new VariableSizeList<ExceptionHandler>(dexBuf, reader.getOffset(), encodedSize) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected DexBackedExceptionHandler readNextItem(@Nonnull DexReader reader, int index) {
|
||||
protected ExceptionHandler readNextItem(@Nonnull DexReader reader, int index) {
|
||||
return new DexBackedExceptionHandler(reader);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
//with catch-all
|
||||
final int sizeWithCatchAll = (-1 * encodedSize) + 1;
|
||||
return new VariableSizeSet<ExceptionHandler>(dexBuf, reader.getOffset(), sizeWithCatchAll) {
|
||||
return new VariableSizeList<ExceptionHandler>(dexBuf, reader.getOffset(), sizeWithCatchAll) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ExceptionHandler readNextItem(@Nonnull DexReader dexReader, int index) {
|
||||
|
@ -32,7 +32,7 @@
|
||||
package org.jf.dexlib2.iface;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents an individual try block and associated set of handlers.
|
||||
@ -59,12 +59,12 @@ public interface TryBlock {
|
||||
int getCodeUnitCount();
|
||||
|
||||
/**
|
||||
* A set of the exception handlers associated with this try block.
|
||||
* A list of the exception handlers associated with this try block.
|
||||
*
|
||||
* The exception handlers in the returned set will all have a unique type, including at most 1 with no type, which
|
||||
* is the catch-all handler.
|
||||
*
|
||||
* @return A set of ExceptionHandler objects
|
||||
* @return A list of ExceptionHandler objects
|
||||
*/
|
||||
@Nonnull Set<? extends ExceptionHandler> getExceptionHandlers();
|
||||
@Nonnull List<? extends ExceptionHandler> getExceptionHandlers();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.base.BaseExceptionHandler;
|
||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||
import org.jf.util.ImmutableConverter;
|
||||
@ -62,9 +62,9 @@ public class ImmutableExceptionHandler extends BaseExceptionHandler implements E
|
||||
@Override public int getHandlerCodeAddress() { return handlerCodeAddress; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableSet<ImmutableExceptionHandler> immutableSetOf(
|
||||
public static ImmutableList<ImmutableExceptionHandler> immutableListOf(
|
||||
@Nullable Iterable<? extends ExceptionHandler> list) {
|
||||
return CONVERTER.toSet(list);
|
||||
return CONVERTER.toList(list);
|
||||
}
|
||||
|
||||
private static final ImmutableConverter<ImmutableExceptionHandler, ExceptionHandler> CONVERTER =
|
||||
|
@ -46,22 +46,22 @@ import java.util.Set;
|
||||
public class ImmutableTryBlock implements TryBlock {
|
||||
protected final int startCodeAddress;
|
||||
protected final int codeUnitCount;
|
||||
@Nonnull protected final ImmutableSet<? extends ImmutableExceptionHandler> exceptionHandlers;
|
||||
@Nonnull protected final ImmutableList<? extends ImmutableExceptionHandler> exceptionHandlers;
|
||||
|
||||
public ImmutableTryBlock(int startCodeAddress,
|
||||
int codeUnitCount,
|
||||
@Nullable Set<? extends ExceptionHandler> exceptionHandlers) {
|
||||
@Nullable List<? extends ExceptionHandler> exceptionHandlers) {
|
||||
this.startCodeAddress = startCodeAddress;
|
||||
this.codeUnitCount = codeUnitCount;
|
||||
this.exceptionHandlers = ImmutableExceptionHandler.immutableSetOf(exceptionHandlers);
|
||||
this.exceptionHandlers = ImmutableExceptionHandler.immutableListOf(exceptionHandlers);
|
||||
}
|
||||
|
||||
public ImmutableTryBlock(int startCodeAddress,
|
||||
int codeUnitCount,
|
||||
@Nullable ImmutableSet<? extends ImmutableExceptionHandler> exceptionHandlers) {
|
||||
@Nullable ImmutableList<? extends ImmutableExceptionHandler> exceptionHandlers) {
|
||||
this.startCodeAddress = startCodeAddress;
|
||||
this.codeUnitCount = codeUnitCount;
|
||||
this.exceptionHandlers = ImmutableUtils.nullToEmptySet(exceptionHandlers);
|
||||
this.exceptionHandlers = ImmutableUtils.nullToEmptyList(exceptionHandlers);
|
||||
}
|
||||
|
||||
public static ImmutableTryBlock of(TryBlock tryBlock) {
|
||||
@ -77,7 +77,7 @@ public class ImmutableTryBlock implements TryBlock {
|
||||
@Override public int getStartCodeAddress() { return startCodeAddress; }
|
||||
@Override public int getCodeUnitCount() { return codeUnitCount; }
|
||||
|
||||
@Nonnull @Override public ImmutableSet<? extends ImmutableExceptionHandler> getExceptionHandlers() {
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableExceptionHandler> getExceptionHandlers() {
|
||||
return exceptionHandlers;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user