Skip to content

Commit 87dd91a

Browse files
committed
BridJ: log missing methods in ObjCProxy even out of debug mode (issue #188)
1 parent 8440e7f commit 87dd91a

5 files changed

Lines changed: 20 additions & 4 deletions

File tree

libraries/Runtime/BridJ/src/main/cpp/bridj/ObjCProxy.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ - (id) initWithEnv: (JNIEnv*)env javaInstance: (jobject)theJavaInstance {
7070
}
7171

7272
- dealloc {
73-
[super dealloc];
7473
JNIEnv* env = GetEnv();
75-
(*env)-> DeleteGlobalRef(env, javaInstance);
74+
(*env)->DeleteGlobalRef(env, javaInstance);
75+
[super dealloc];
7676
}
7777

7878
- (void)forwardInvocation: (NSInvocation*)invocation {

libraries/Runtime/BridJ/src/main/java/org/bridj/objc/ObjCProxy.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,20 @@ Pair<NSMethodSignature, Method> computeMethodAndSignature(SEL sel) {
7575
return new Pair<NSMethodSignature, Method>(ms, method);
7676
}
7777
}
78-
if (BridJ.debug)
79-
BridJ.log(Level.INFO, "Failed to compute method and signature for selector " + sel + " in class " + getInvocationTarget().getClass().getName());
78+
//if (BridJ.debug)
79+
BridJ.log(Level.SEVERE, "Missing method for " + sel + " in class " + classHierarchyToString(getInvocationTarget().getClass()));
8080

8181
return null;
8282
}
83+
static String classHierarchyToString(Class c) {
84+
String s = Utils.toString(c);
85+
Type p = c.getGenericSuperclass();
86+
while (p != null && p != Object.class && p != ObjCProxy.class) {
87+
s += " extends " + Utils.toString(p);
88+
p = Utils.getClass(p).getGenericSuperclass();
89+
}
90+
return s;
91+
}
8392
/*
8493
static Type promote(Type type) {
8594
if (type == byte.class || type == short.class || type == char.class || type == boolean.class)
Binary file not shown.
Binary file not shown.

libraries/Runtime/BridJ/src/main/velocity/org/bridj/Pointer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,13 @@ public T get() {
893893
return get(0);
894894
}
895895

896+
/**
897+
* Returns null if pointer is null, otherwise dereferences the pointer (calls pointer.get()).
898+
*/
899+
public static <T> T get(Pointer<T> pointer) {
900+
return pointer == null ? null : pointer.get();
901+
}
902+
896903
/**
897904
Gets the n-th element from this pointer.<br>
898905
This is equivalent to the C/C++ square bracket syntax.<br>

0 commit comments

Comments
 (0)