Skip to content

Commit aeaad31

Browse files
authored
* Fix Generator flakiness caused by calls to Class.getDeclaredMethods() (pull bytedeco#784)
1 parent 2fd35c6 commit aeaad31

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Fix `Generator` flakiness caused by calls to `Class.getDeclaredMethods()` ([pull #784](https://github.com/bytedeco/javacpp/pull/784))
23
* Add minimal mappings for `std::chrono` from C++11 ([pull #766](https://github.com/bytedeco/javacpp/pull/766))
34
* Let `Parser` annotate Java constructors with `@Deprecated` when appropriate ([pull #757](https://github.com/bytedeco/javacpp/pull/757))
45
* Add to `InfoMap.defaults` more names that are reserved in Java, but not in C++ ([pull #757](https://github.com/bytedeco/javacpp/pull/757))

src/main/java/org/bytedeco/javacpp/tools/Generator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,7 @@ boolean methods(Class<?> cls) {
21162116
c = c.getSuperclass();
21172117
}
21182118
boolean[] callbackAllocators = new boolean[methods.length];
2119-
Method[] functionMethods = functionMethods(cls, callbackAllocators);
2119+
Method[] functionMethods = functionMethods(cls, methods, callbackAllocators);
21202120
boolean firstCallback = true;
21212121
for (int i = 0; i < methods.length; i++) {
21222122
if (!Loader.checkPlatform(methods[i].getAnnotation(Platform.class), properties)) {
@@ -3636,11 +3636,10 @@ static String functionClassName(Class<?> cls) {
36363636
return name != null ? name.value()[0] : "JavaCPP_" + mangle(cls.getName());
36373637
}
36383638

3639-
static Method[] functionMethods(Class<?> cls, boolean[] callbackAllocators) {
3639+
static Method[] functionMethods(Class<?> cls, Method[] methods, boolean[] callbackAllocators) {
36403640
if (!FunctionPointer.class.isAssignableFrom(cls)) {
36413641
return null;
36423642
}
3643-
Method[] methods = cls.getDeclaredMethods();
36443643
Method[] functionMethods = new Method[3];
36453644
for (int i = 0; i < methods.length; i++) {
36463645
String methodName = methods[i].getName();
@@ -4386,7 +4385,7 @@ String[] cppTypeName(Class<?> type, Annotation[] annotations) {
43864385
} else if (type.isPrimitive()) {
43874386
prefix = type.getName();
43884387
} else if (FunctionPointer.class.isAssignableFrom(type)) {
4389-
Method[] functionMethods = functionMethods(type, null);
4388+
Method[] functionMethods = functionMethods(type, type.getDeclaredMethods(), null);
43904389
String[] prefixSuffix = cppFunctionTypeName(functionMethods);
43914390
if (prefixSuffix != null) {
43924391
return prefixSuffix;

0 commit comments

Comments
 (0)