Skip to content

Commit

Permalink
* Fix Generator flakiness caused by calls to `Class.getDeclaredMet…
Browse files Browse the repository at this point in the history
…hods()` (pull #784)
  • Loading branch information
Ethan-Chin authored Oct 28, 2024
1 parent 2fd35c6 commit aeaad31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/bytedeco/javacpp/tools/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit aeaad31

Please sign in to comment.