Skip to content

No unused method warning raised on specific pattern #4724

@nbauma109

Description

@nbauma109

I'm using this code pattern:

public class TestUnusedMethod {
	enum SampleEnum {
		A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k,
		l, m, n, o, p, q, r, s, t, u, v, w, x, y;
	}

	void methodWithSwitches(SampleEnum input) {
		switch (input) {
		case A:
		}

		switch (input) {
		case B:
		}
	}

	private void unusedMethod() {
	}
}

Eclipse didn't notice unusedMethod was unused.

If I do any of the below actions, Eclipse instantly notices unusedMethod is unused and marks it as yellow :

  • remove one of the 2 switch blocks
  • remove one of the enum constants

Eclipse version:
2025-12

Java version:
21

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions