Skip to content

Commit

Permalink
Uniformize API of StackLocator versions (#3340)
Browse files Browse the repository at this point in the history
The Java 9 version of `StackLocator` has an additional public `getCallerClass(String)` method. This method makes the Java 8 and 9 versions of `StackLocator` expose different APIs to the user. To prevent API compatibility problems, we remove the additional method.

This incompatibility was accidentally discovered during the work in #3339: `japicmp` did randomly compare a `StackLocator` class from the old version with a `StackLocator` class from the new version.

This is part of #1867.
  • Loading branch information
ppkarwasz authored Dec 30, 2024
1 parent eb4f792 commit cb46e63
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public Class<?> getCallerClass(final Class<?> sentinelClass, final Predicate<Cla
.orElse(null));
}

public Class<?> getCallerClass(final String fqcn) {
return getCallerClass(fqcn, "");
}

public Class<?> getCallerClass(final String fqcn, final String pkg) {
return WALKER.walk(s -> s.dropWhile(f -> !f.getClassName().equals(fqcn))
.dropWhile(f -> f.getClassName().equals(fqcn))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static class Inner {
private static void assertCallerClassViaName() {
final Class<?> expected = StackLocatorTest.class;
final StackLocator stackLocator = StackLocator.getInstance();
final Class<?> actual = stackLocator.getCallerClass(Inner.class.getName());
final Class<?> actual = stackLocator.getCallerClass(Inner.class.getName(), "");
assertSame(expected, actual);
}

Expand Down

0 comments on commit cb46e63

Please sign in to comment.