[Kde-java] QtJava api via Dynamic Proxies progress - part 1

Mark Wielaard mark at klomp.org
Thu Aug 21 15:46:54 CEST 2003


Hi [CCed to gcj developers mailinglist - from kde java bindings
mailinglist, discussion about QT java bindings trhough Proxy classes],

On Thu, 2003-08-21 at 14:24, Richard Dale wrote:
> On Thursday 21 August 2003 12:41, Gert-Jan van der Heiden wrote:
> >
> > 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..

I tried to see what goes wrong with the libgcj Proxy implementation, but
I am not to familiar with this code and couldn't immediately find it. If
you have a small example (that doesn't need the QT library) that would
help.

Our current Proxy implementation actually generates byte code for the
Proxy class that is then read in with defineClass() and interpreted by
the interpreter. There are hooks in java.lang.reflect.Proxy to do some
magic to not need the interpreter which would make these kind of things
faster. But I don't know how much work it would be to implement that.

Cheers,

Mark



More information about the Kde-java mailing list