20package com.sun.star.bridges.jni_uno;
31public final class JNI_proxy implements java.lang.reflect.InvocationHandler
34 if (
"The Android Project".equals(
System.getProperty(
"java.vendor"))) {
39 boolean disable_dynloading =
false;
41 System.loadLibrary(
"lo-bootstrap");
42 }
catch (UnsatisfiedLinkError e) {
43 disable_dynloading =
true;
46 if (!disable_dynloading)
50 NativeLibraryLoader.loadLibrary(
JNI_proxy.class.getClassLoader(),
56 new Class [] { java.lang.reflect.InvocationHandler.class };
71 boolean current_trace =
false;
72 if (
null == throwable)
74 throwable =
new Throwable();
77 java.io.StringWriter string_writer =
78 new java.io.StringWriter();
79 java.io.PrintWriter print_writer =
80 new java.io.PrintWriter( string_writer,
true );
81 throwable.printStackTrace( print_writer );
84 string_writer.flush();
85 String trace = string_writer.toString();
89 int n = trace.indexOf(
'\n' );
90 n = trace.indexOf(
'\n',
n +1 );
91 trace = trace.substring(
n +1 );
93 return "\njava stack trace:\n" + trace;
103 public void run() throws Throwable {
104 JNI_proxy.this.finalize( m_bridge_handle );
111 long bridge_handle, IEnvironment java_env,
112 long receiver_handle,
long td_handle, Type type, String oid,
113 AsynchronousFinalizer finalizer)
115 m_bridge_handle = bridge_handle;
116 m_java_env = java_env;
117 m_receiver_handle = receiver_handle;
118 m_td_handle = td_handle;
121 m_class =
m_type.getZClass();
122 m_finalizer = finalizer;
126 long bridge_handle, IEnvironment java_env,
127 long receiver_handle,
long td_handle, Type type, String oid,
128 java.lang.reflect.Constructor proxy_ctor,
129 AsynchronousFinalizer finalizer)
133 bridge_handle, java_env, receiver_handle, td_handle,
type, oid,
135 Object proxy = proxy_ctor.newInstance(
new Object [] { handler } );
136 return java_env.registerInterface( proxy,
new String [] { oid },
type );
142 Class proxy_class = java.lang.reflect.Proxy.getProxyClass(
144 new Class [] { clazz, IQueryInterface.class,
146 return proxy_class.getConstructor( s_InvocationHandler );
150 long bridge_handle, String method, Object args [] )
156 Object proxy, java.lang.reflect.Method method, Object args [] )
159 Class<?> decl_class = method.getDeclaringClass();
160 String method_name = method.getName();
162 if (
Object.class.equals( decl_class ))
164 if (method_name.equals(
"hashCode" ))
169 else if (method_name.equals(
"equals" ))
172 return isSame(
args[0]);
174 else if (method_name.equals(
"toString" ))
178 ", type=" +
m_type.getTypeName() +
"]";
182 else if (decl_class.isAssignableFrom( m_class ))
185 return dispatch_call( m_bridge_handle, method_name,
args );
188 else if (IQueryInterface.class.equals( decl_class ))
190 if (method_name.equals(
"queryInterface" ))
194 if (
null == registered_proxy)
196 return dispatch_call( m_bridge_handle, method_name,
args );
200 return registered_proxy;
203 else if (method_name.equals(
"isSame" ))
206 return isSame(
args[0]);
208 else if (method_name.equals(
"getOid" ))
215 "[jni_uno bridge error] unexpected call on proxy " +
216 proxy.toString() +
": " + method.toString() );
220 return Boolean.valueOf(obj !=
null
221 &&
m_oid.equals(UnoRuntime.generateOid(obj)));
static java.lang.reflect.Constructor get_proxy_ctor(Class clazz)
static String get_stack_trace(Throwable throwable)
static Object create(long bridge_handle, IEnvironment java_env, long receiver_handle, long td_handle, Type type, String oid, java.lang.reflect.Constructor proxy_ctor, AsynchronousFinalizer finalizer)
native void finalize(long bridge_handle)
JNI_proxy(long bridge_handle, IEnvironment java_env, long receiver_handle, long td_handle, Type type, String oid, AsynchronousFinalizer finalizer)
final AsynchronousFinalizer m_finalizer
native Object dispatch_call(long bridge_handle, String method, Object args[])
Object invoke(Object proxy, java.lang.reflect.Method method, Object args[])
long m_receiver_handle
these 2 fields are accessed directly from C++
static ClassLoader s_classloader
static Class s_InvocationHandler[]
Boolean isSame(Object obj)
final IEnvironment m_java_env
OUString toString(OptionInfo const *info)