[Kde-java] QtJava api via Dynamic Proxies progress - part 1
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Thu Aug 21 14:24:54 CEST 2003
On Thursday 21 August 2003 12:41, Gert-Jan van der Heiden wrote:
> On Thursday 21 August 2003 10:36, Richard Dale wrote:
> > On Thursday 21 August 2003 08:05, Gert-Jan van der Heiden wrote:
> > > On Wednesday 20 August 2003 05:36, Richard Dale wrote:
> > > > I've got kalyptus correctly auto-generating the QtJava sources so
> > > > that they compile without error, all 60000 lines! So there shouldn't
> > > > be any need to put the autogenerated code in the cvs anymore, it can
> > > > be generated on demand.
> > >
> > > That is good news
> > >
> > > > Here are the build instructions from the README file, to try it out:
> > > >
> > > > A Java SMOKE adaptor based on Dynamic Proxies
> > > >
> > > > * Copy kalyptusCxxToJava.pm and kalyptusDataDict.pm to
> > > > ...
> > >
> > > Can this be done based on the latest stable KDE release (3.1.3) ? I see
> > > no reason why it shouldn't. I'm going to try it.
> >
> > I've only used the Qt headers, it should work with any version of Qt 3.x
> > - I haven't considered KDE code generation yet. It still doesn't do a
> > lot, so I don't want to oversell it - more it proves that the idea of
> > using Proxies will work. It should take about a couple of weeks to redo
> > the QtJava runtime to work with SMOKE. It will be ready for KDE 3.2 I
> > think.
>
> Yes, I saw SmokeInvocation. Guess the translation from Java to C++ is
> missing too? And of course the "callbacks" (slots / signals and virtual
> methods).
The way slots/signals work will stay the same - the code won't need changing.
To call a method when there are two or more with the same name, it will need
to do a runtime comparison of the java argument types with the C++ types of
the arguments (available as strings from the SMOKE runtime) to tell which
actual C++ method to invoke.
The virtual method callbacks are done by SMOKE, so no java-specific C++ code
needs to be generated at all, just code to translate the SMOKE callback to a
java reflection based call, if the virtual method has been overriden in java.
> > I'll check any changes into the HEAD branch, and I assume KDE 3.1.3 is
> > based on the KDE_3_1_BRANCH so any fixes for the old style java bindings
> > could go in there. I didn't even realise there was a KDE 3.1.3 release -
> > I hope the bindings for that built ok.
>
> Well, I just compiled kalyptus with kdebindings-3.1.3 (and current CVS
> version). That went ok, using JDK 1.4.2.
>
> I tried to compile and run it with GCJ, that didn't went so well...
>
> $ gcj --version
> gcj (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> $ gcj qt/Doit.java qt/QFont.java qt/SmokeInvocation.java \
> qt/QtSupport.java qt/Qt.java -o doit --main=qt.Doit
> $ ./doit
>
> java.lang.InternalError: Unexpected:
> java.lang.reflect.InvocationTargetException
> at java.lang.reflect.Proxy$ClassFactory.generate(java.lang.ClassLoader)
> (/usr/lib/libgcj.so.4.0.0)
> at java.lang.reflect.Proxy.getProxyClass(java.lang.ClassLoader,
> java.lang.Class[]) (/usr/lib/libgcj.so.4.0.0)
> at java.lang.reflect.Proxy.newProxyInstance(java.lang.ClassLoader,
> java.lang.Class[], java.lang.reflect.InvocationHandler)
> (/usr/lib/libgcj.so.4.0.0)
> at qt.QFont.<clinit>() (Unknown Source)
> at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.4.0.0)
> at _Jv_AllocObjectNoFinalizer (/usr/lib/libgcj.so.4.0.0)
> at _Jv_AllocObject (/usr/lib/libgcj.so.4.0.0)
> at qt.Doit.main(java.lang.String[]) (Unknown Source)
> Caused by: java.lang.reflect.InvocationTargetException
> at _Jv_CallAnyMethodA(java.lang.Object, java.lang.Class, _Jv_Method,
> boolean, java.lang.Class[], jvalue, jvalue) (/usr/lib/libgcj.so.4.0.0)
> at _Jv_CallAnyMethodA(java.lang.Object, java.lang.Class, _Jv_Method,
> boolean, java.lang.Class[], java.lang.Object[]) (/usr/lib/libgcj.so.4.0.0)
> at java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])
> (/usr/lib/libgcj.so.4.0.0)
> at java.lang.reflect.Proxy$ClassFactory.generate(java.lang.ClassLoader)
> (/usr/lib/libgcj.so.4.0.0)
> ...7 more
> Caused by: java.lang.IncompatibleClassChangeError: $Proxy0
> at _Jv_ClassReader.checkImplements(java.lang.Class, java.lang.Class)
> (/usr/lib/libgcj.so.4.0.0)
> at _Jv_ClassReader.handleInterface(int, int) (/usr/lib/libgcj.so.4.0.0)
> at _Jv_ClassReader.parse() (/usr/lib/libgcj.so.4.0.0)
> at _Jv_DefineClass(java.lang.Class, byte[], int, int)
> (/usr/lib/libgcj.so.4.0.0)
> at java.lang.ClassLoader.defineClass0(java.lang.String, byte[], int,
> int, java.security.ProtectionDomain) (/usr/lib/libgcj.so.4.0.0)
> at java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int,
> java.security.ProtectionDomain) (/usr/lib/libgcj.so.4.0.0)
> at java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int)
> (/usr/lib/libgcj.so.4.0.0)
> at java.lang.VMClassLoader.defineClass(java.lang.ClassLoader,
> java.lang.String, byte[], int, int) (/usr/lib/libgcj.so.4.0.0)
> at _Jv_CallAnyMethodA(java.lang.Object, java.lang.Class, _Jv_Method,
> boolean, java.lang.Class[], jvalue, jvalue) (/usr/lib/libgcj.so.4.0.0)
> ...10 more
>
> I changed the classloader statement as Marco Ladermann stated, no change.
>
> Then I declared QFontProtectedInterface public
> (protected interfaceProtected QFontProtectedInterface to
> public interfaceProtected QFontProtectedInterface ) .
So it still allowed the public interface method to be implemented by a
protected method, if you didn't need to change the actual implemention.
Because QFontProtectedInterface is only internal it wouldn't matter if it
had to be public.
> This familiar output appeared:
>
> $ ./doit
> SmokeInvocation()
> SmokeInvocation(obj)
> SmokeInvocation.invoke: public abstract void
> qt.QFont$QFontProtectedInterface.newQFont()
> SmokeInvocation.invoke: public abstract void
> qt.QFont$QFontPublicInterface.setPointSize(int)
> SmokeInvocation.invoke: public abstract java.lang.String
> qt.QFont$QFontPublicInterface.substitute(java.lang.String)
>
>
> Though my compiler isn't a official release, I 3.3 is released in may, and
> early this month (8 aug) 3.3.1 is released.
Good, interesting - worth knowing this early on. I'll put the new kalyptus
code generation in the cvs so we can tweak it without having to send
attachments to the kdejava list..
-- Richard
More information about the Kde-java
mailing list