mirror of
https://github.com/revanced/smali.git
synced 2025-05-06 09:24:33 +02:00
Add ExceptionHandler.getExceptionTypeReference method
This commit is contained in:
parent
f320ed5293
commit
a4e0efe9a5
@ -33,13 +33,28 @@ package org.jf.dexlib2.base;
|
|||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
import org.jf.dexlib2.base.reference.BaseTypeReference;
|
||||||
import org.jf.dexlib2.iface.ExceptionHandler;
|
import org.jf.dexlib2.iface.ExceptionHandler;
|
||||||
|
import org.jf.dexlib2.iface.reference.TypeReference;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public abstract class BaseExceptionHandler implements ExceptionHandler {
|
public abstract class BaseExceptionHandler implements ExceptionHandler {
|
||||||
|
@Nullable @Override public TypeReference getExceptionTypeReference() {
|
||||||
|
final String exceptionType = getExceptionType();
|
||||||
|
if (exceptionType == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BaseTypeReference() {
|
||||||
|
@Nonnull @Override public String getType() {
|
||||||
|
return exceptionType;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
String exceptionType = getExceptionType();
|
String exceptionType = getExceptionType();
|
||||||
@ -76,6 +91,8 @@ public abstract class BaseExceptionHandler implements ExceptionHandler {
|
|||||||
return Ints.compare(getHandlerCodeAddress(), o.getHandlerCodeAddress());
|
return Ints.compare(getHandlerCodeAddress(), o.getHandlerCodeAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final Comparator<ExceptionHandler> BY_EXCEPTION = new Comparator<ExceptionHandler>() {
|
public static final Comparator<ExceptionHandler> BY_EXCEPTION = new Comparator<ExceptionHandler>() {
|
||||||
@Override public int compare(ExceptionHandler o1, ExceptionHandler o2) {
|
@Override public int compare(ExceptionHandler o1, ExceptionHandler o2) {
|
||||||
String exceptionType1 = o1.getExceptionType();
|
String exceptionType1 = o1.getExceptionType();
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.iface;
|
package org.jf.dexlib2.iface;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.iface.reference.TypeReference;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -45,6 +47,14 @@ public interface ExceptionHandler extends Comparable<ExceptionHandler> {
|
|||||||
*/
|
*/
|
||||||
@Nullable String getExceptionType();
|
@Nullable String getExceptionType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of exception that is handled by this handler.
|
||||||
|
*
|
||||||
|
* @return A TypeReference to the type of exception that is handled by this handler, or null if this is a
|
||||||
|
* catch-all handler.
|
||||||
|
*/
|
||||||
|
@Nullable TypeReference getExceptionTypeReference();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the code offset of the handler.
|
* Gets the code offset of the handler.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user