BAEL-4384: Invoke a private method using reflection (#10470)

* - initial commit of sample code

* BAEL-4209:  Moving the localized exception module into core-java-exceptions-3.

* BAEL-4209: Removed the old files for localizing exception messages.

* Added test case to explain invoking a private method.

* Made the code example more useful so we don't look like we're hacking another framework.

* Forgot to make the test class and method package-private.

* Incorporated Spring ReflectionTestUtils into the code sample.

* Updated the Spring Test version to match the article.
This commit is contained in:
Bradley M Handy
2021-03-03 14:44:45 -05:00
committed by GitHub
parent 1344b5071d
commit 7fa7dfa7d2
3 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package com.baeldung.reflection.access.privatemethods;
public class LongArrayUtil {
public static int indexOf(long[] array, long target) {
return indexOf(array, target, 0, array.length);
}
private static int indexOf(long[] array, long target, int start, int end) {
for (int i = start; i < end; i++) {
if (array[i] == target) {
return i;
}
}
return -1;
}
}