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 existingType = existingHandler.getExceptionType();
|
||||||
String newType = handler.getExceptionType();
|
String newType = handler.getExceptionType();
|
||||||
|
|
||||||
// Don't add it if we already have a handler of the same type
|
|
||||||
if (existingType == null) {
|
if (existingType == null) {
|
||||||
if (newType == null) {
|
if (newType == null) {
|
||||||
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
|
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
|
||||||
@ -176,10 +175,9 @@ public class TryListBuilder<EH extends ExceptionHandler>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (existingType.equals(newType)) {
|
} else if (existingType.equals(newType)) {
|
||||||
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
|
// dalvik doesn't reject cases when there are multiple catches with the same exception
|
||||||
throw new InvalidTryException(
|
// but different handlers. In practice, the first handler "wins". Since the later
|
||||||
"Multiple overlapping catches for %s with different handlers", existingType);
|
// handler will never be used, we don't add it.
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,12 +449,8 @@ public class TryListBuilderTest {
|
|||||||
TryListBuilder tlb = new TryListBuilder();
|
TryListBuilder tlb = new TryListBuilder();
|
||||||
|
|
||||||
tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
|
tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
|
||||||
try {
|
tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException1;", 6));
|
||||||
tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException1;", 6));
|
// no exception should be thrown...
|
||||||
} catch (TryListBuilder.InvalidTryException ex) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Assert.fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user