diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b379e7..c592137f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Fix `Generator` flakiness caused by calls to `Class.getDeclaredMethods()` ([pull #784](https://github.com/bytedeco/javacpp/pull/784)) * Add minimal mappings for `std::chrono` from C++11 ([pull #766](https://github.com/bytedeco/javacpp/pull/766)) * Let `Parser` annotate Java constructors with `@Deprecated` when appropriate ([pull #757](https://github.com/bytedeco/javacpp/pull/757)) * Add to `InfoMap.defaults` more names that are reserved in Java, but not in C++ ([pull #757](https://github.com/bytedeco/javacpp/pull/757)) diff --git a/src/main/java/org/bytedeco/javacpp/tools/Generator.java b/src/main/java/org/bytedeco/javacpp/tools/Generator.java index e703ca31..cb41b19a 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Generator.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Generator.java @@ -2116,7 +2116,7 @@ boolean methods(Class cls) { c = c.getSuperclass(); } boolean[] callbackAllocators = new boolean[methods.length]; - Method[] functionMethods = functionMethods(cls, callbackAllocators); + Method[] functionMethods = functionMethods(cls, methods, callbackAllocators); boolean firstCallback = true; for (int i = 0; i < methods.length; i++) { if (!Loader.checkPlatform(methods[i].getAnnotation(Platform.class), properties)) { @@ -3636,11 +3636,10 @@ static String functionClassName(Class cls) { return name != null ? name.value()[0] : "JavaCPP_" + mangle(cls.getName()); } - static Method[] functionMethods(Class cls, boolean[] callbackAllocators) { + static Method[] functionMethods(Class cls, Method[] methods, boolean[] callbackAllocators) { if (!FunctionPointer.class.isAssignableFrom(cls)) { return null; } - Method[] methods = cls.getDeclaredMethods(); Method[] functionMethods = new Method[3]; for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); @@ -4386,7 +4385,7 @@ String[] cppTypeName(Class type, Annotation[] annotations) { } else if (type.isPrimitive()) { prefix = type.getName(); } else if (FunctionPointer.class.isAssignableFrom(type)) { - Method[] functionMethods = functionMethods(type, null); + Method[] functionMethods = functionMethods(type, type.getDeclaredMethods(), null); String[] prefixSuffix = cppFunctionTypeName(functionMethods); if (prefixSuffix != null) { return prefixSuffix;