Skip to content

Improve FinallyFilter #2020

@Godin

Description

@Godin
class Example {
	private static String example(int i) {
		try {
			switch (i) {
			case 0:
				return "case 0";
			case 1:
				return "case 1";
			}
		} finally {
			System.out.println(i == 0); // currently 1 of 4 branches missed
		}
		return "";
	}

	public static void main(String[] args) {
		example(0);
		example(1);
		example(2);
	}
}

switch

  • is last inside try-finally
  • without default
  • return in all cases

class Example {
	public static void main(String[] args) {
		loop: for (int i = 0; i <= 5; i++) {
			try {
				switch (i) {
				case 1:
					System.out.println("case 1");
					break;
				case 5:
					break loop;
				default:
					System.out.println("default");
					break;
				}
				System.out.println();
			} finally {
				System.out.println(i == 0); // currently 1 of 4 branches missed
			}
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions