mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Allow but ignore multiple exception handlers for the same exception
This commit is contained in:
parent
3d2e935f08
commit
394bb25b7c
@ -166,7 +166,6 @@ public class TryListBuilder<EH extends ExceptionHandler>
|
||||
String existingType = existingHandler.getExceptionType();
|
||||
String newType = handler.getExceptionType();
|
||||
|
||||
// Don't add it if we already have a handler of the same type
|
||||
if (existingType == null) {
|
||||
if (newType == null) {
|
||||
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
|
||||
@ -176,10 +175,9 @@ public class TryListBuilder<EH extends ExceptionHandler>
|
||||
return;
|
||||
}
|
||||
} else if (existingType.equals(newType)) {
|
||||
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
|
||||
throw new InvalidTryException(
|
||||
"Multiple overlapping catches for %s with different handlers", existingType);
|
||||
}
|
||||
// dalvik doesn't reject cases when there are multiple catches with the same exception
|
||||
// but different handlers. In practice, the first handler "wins". Since the later
|
||||
// handler will never be used, we don't add it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -449,12 +449,8 @@ public class TryListBuilderTest {
|
||||
TryListBuilder tlb = new TryListBuilder();
|
||||
|
||||
tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
|
||||
try {
|
||||
tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException1;", 6));
|
||||
} catch (TryListBuilder.InvalidTryException ex) {
|
||||
return;
|
||||
}
|
||||
Assert.fail();
|
||||
// no exception should be thrown...
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user