It had never even crossed my mind until today, but it turns out that a java finally clause is allowed to overwrite the return value. This example prints 0 rather than 1.

package com.kstruct;

public class Main {

	public static void main(String[] args) {

	private static int test() {
		try {
			return 1;
		} finally {
			return 0;

That could get really confusing in a long / complex / poorly written function…

…and apparently things get worse and worse the more you look into them.