1.1 --- a/javaclass/bytecode.py Sun Jan 23 23:52:39 2005 +0100
1.2 +++ b/javaclass/bytecode.py Mon Jan 24 00:46:54 2005 +0100
1.3 @@ -746,9 +746,35 @@
1.4
1.5 # NOTE: Strange case with javac from JDK 1.4 but not JDK 1.3:
1.6 # NOTE: start_pc == handler_pc
1.7 -
1.8 - if exception.start_pc == exception.handler_pc:
1.9 - continue
1.10 + # Merge all finally handlers with the same handler location.
1.11 +
1.12 + if exception.catch_type == 0 and exception_block_handler.get(exception.handler_pc, []) != []:
1.13 +
1.14 + # Make a new definition.
1.15 +
1.16 + new_exception = classfile.ExceptionInfo()
1.17 + new_exception.catch_type = exception.catch_type
1.18 + new_exception.handler_pc = exception.handler_pc
1.19 + new_exception.end_pc = exception.end_pc
1.20 + new_exception.start_pc = exception.start_pc
1.21 +
1.22 + # Find the previous exception handler definition.
1.23 +
1.24 + for previous_exception in exception_block_handler[exception.handler_pc][:]:
1.25 + if previous_exception.catch_type == 0:
1.26 + new_exception.end_pc = max(new_exception.end_pc, previous_exception.end_pc)
1.27 + new_exception.start_pc = min(new_exception.start_pc, previous_exception.start_pc)
1.28 +
1.29 + # Remove this exception from the lists.
1.30 +
1.31 + exception_block_handler[previous_exception.handler_pc].remove(previous_exception)
1.32 + exception_block_start[previous_exception.start_pc].remove(previous_exception)
1.33 + exception_block_end[previous_exception.end_pc].remove(previous_exception)
1.34 + break
1.35 +
1.36 + # Use the new definition instead.
1.37 +
1.38 + exception = new_exception
1.39
1.40 # Index start positions.
1.41