Hi there,
a little update: unfortunately I get into the situation that I cannot
instantiate the Introspection class via Java reflection with both, 1.1.4
and the latest 1.9. Cleaning the registry does not change the phenomenon
(so I assume that a total de-install and deleting of left-over files a
cleaning of the registry for left-over traces of OOo, a reboot
thereafter and a fresh install is the only means to get by it). Will be
conducting additional tests to find out, what causes that behaviour (in
order to be able to fix or circumvent it).
Whenever I run into this state, the following Java program (modeled
after Stephan's) will not be able to instantiate
'com.sun.star.beans.Introspection'. OTOH with the compiled Java program
it is possible to instantiate 'com.sun.star.reflection.CoreReflection',
which seems not to be possible if using the Java reflection mechanism.
Here's the Java program, followed by its output:
----------------- cut here ------------------
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XIntrospection;
import com.sun.star.beans.XIntrospectionAccess;
import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.UnoUrlResolver;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.frame.FrameSearchFlag;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
// rgf, 2005-07-16
import com.sun.star.reflection.XIdlClass;
import com.sun.star.reflection.XIdlField;
import com.sun.star.reflection.XIdlMethod;
import com.sun.star.reflection.XIdlReflection;
// import org.rexxla.bsf.engines.rexx.ArrayWrapper;
public final class IntrospectBug {
public static void main(String[] arguments) throws Exception {
// if port as (only) argument given, use that to establish a
connection
String portNr= (arguments.length==0 ? "12345" : arguments[0] );
XMultiComponentFactory factory = (XMultiComponentFactory)
UnoRuntime.queryInterface(
XMultiComponentFactory.class,
(UnoUrlResolver.create(Bootstrap.createInitialComponentContext(null)).
resolve("uno:socket,host=127.0.0.1,port="+portNr+
";urp;StarOffice.ServiceManager")
)
);
System.out.println("factory="+pp(factory));
XComponentContext context = (XComponentContext)
UnoRuntime.queryInterface(
XComponentContext.class,
(((XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, factory)).
getPropertyValue("DefaultContext"))
);
System.out.println("context="+pp(context));
XIntrospection introsp =
(XIntrospection) UnoRuntime.queryInterface(
XIntrospection.class,
factory.createInstanceWithContext("com.sun.star.beans.Introspection",
context)
);
System.out.println("introsp="+pp(introsp));
XIdlReflection idlRefl =
(XIdlReflection) UnoRuntime.queryInterface(
XIdlReflection.class,
factory.createInstanceWithContext("com.sun.star.reflection.CoreReflection",
context)
);
System.out.println("idlRefl="+pp(idlRefl));
XComponentLoader compLoader =
(XComponentLoader) UnoRuntime.queryInterface(
XComponentLoader.class,
factory.createInstanceWithContext("com.sun.star.frame.Desktop", context)
);
System.out.println("compLoader="+pp(compLoader));
if (introsp!=null)
{
XIntrospectionAccess introspAccess =
(XIntrospectionAccess)
introsp.inspect(compLoader.loadComponentFromURL(
"private:factory/scalc", "_blank",
FrameSearchFlag.CREATE, new PropertyValue[0])
);
System.out.println("introspAccess="+pp(introspAccess));
}
else
{
System.out.println("No instance of
'com.sun.star.beans.Introspection' available, hence no introspect()!");
}
System.out.println("\n--- --- ---\n");
XIdlClass frameXModel =
idlRefl.forName("com.sun.star.frame.XModel");
System.out.println("frameXModel="+pp(frameXModel));
XIdlMethod [] fxmMethods = frameXModel.getMethods();
System.out.println("fxmMethods="+pp(fxmMethods));
System.out.println("fxmMethods.length="+fxmMethods.length);
XIdlField [] fxmFields = frameXModel.getFields();
System.out.println("fxmFields="+pp(fxmFields));
System.out.println("fxmFields.length="+fxmFields.length);
System.exit(0);
}
private IntrospectBug() {}
public static String pp(Object o)
{
if (o==null) return "<null> <=== <=== <===";
return "<"+o.toString()+">";
}
}
----------------- cut here ------------------
Output, if in erroneous state (in this case OOo 1.9.113):
----------------- cut here ------------------
factory=<[Proxy:1012673,352220;msci[0];9e38bd61f76011d9a7abe7f959e4e7f2,Type[com.sun.star.lang.XMultiComponentFactory]]>
context=<[Proxy:15054627,3578c0;msci[0];9e38bd61f76011d9a7abe7f959e4e7f2,Type[com.sun.star.uno.XComponentContext]]>
introsp=<null> <=== <=== <===
idlRefl=<[Proxy:11060360,654dd78;msci[0];9e38bd61f76011d9a7abe7f959e4e7f2,Type[com.sun.star.reflection.XIdlReflection]]>
compLoader=<[Proxy:1892095,3c0949c;msci[0];9e38bd61f76011d9a7abe7f959e4e7f2,Type[com.sun.star.frame.XComponentLoader]]>
No instance of 'com.sun.star.beans.Introspection' available, hence no
introspect()!
--- --- ---
frameXModel=<[Proxy:10711912,65647b0;msci[0];9e38bd61f76011d9a7abe7f959e4e7f2,Type[com.sun.star.reflection.XIdlClass]]>
fxmMethods=<[Lcom.sun.star.reflection.XIdlMethod;@77158a>
fxmMethods.length=17
fxmFields=<[Lcom.sun.star.reflection.XIdlField;@27391d>
fxmFields.length=0
----------------- cut here ------------------
If you know of any places where the Java runtime of OOo could cache or
externalize Java-related data, classes, exceptions etc., please let me know.
Will be on the road the next days and experiment a little bit further
with this, so any ideas, input would be welcome.
Regards,
---rony
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]