Lightweight peer implementation

Thomas Fitzsimmons fitzsim@redhat.com
Wed Aug 13 17:34:00 GMT 2003


On Tue, 2003-08-12 at 10:47, Scott Gilbertson wrote:
> > > Bryce wrote:
> > >> Yup, I agree. Lightweights should be implemented entirely in the
> > >> "generic" part of the code, not in the peer code.
> > > Thanks, guys.  I've been trying to get someone to express an opinion
> > > one way
> > > or the other on this issue for some time.  I look forward to getting
> > > the
> > > lightweight components issue off my "pending" list.
> > >
> > > I agree with all of what Bryce said:
> > >  - lightweights should be generic
> > >  - there should be no need to check for a null peer
> >
> > Well, I actually said there might be reason to check for null peer. In
> > the JRE implementation, creation of the peers doesn't happen until the
> > component is added to a container and/or its made visible. Just
> > guessing - but this might be because some windowing systems don't allow
> > the native widget to be created unless it already has a parent?
> 
> An alternative would be to have a single static instance of a "really
> lightweight" peer, which returns nulls for everything, and make that the
> Component's peer until the real one is set.  You'd get a slight performance
> boost, by eliminating a comparison statement in the common case where the
> peer has already been set up (at least on architectures where a virtual
> method call is faster than a conditional branch).
> 

OK, here is another patch that builds on Scott's.  I've left the
Component null checks alone for now.  The patch moves GLightweightPeer
to gnu.java.awt.peer and implements some of the missing ComponentPeer
methods.

Comments?

Thanks,
Tom

2003-08-13  Scott Gilbertson  <scottg@mantatest.com>
	    Thomas Fitzsimmons  <fitzsim@redhat.com>

	* Makefile.am (gtk_awt_peer_sources): Add
	gnu/java/awt/peer/GLightweightPeer.java.  Remove
	gnu/java/awt/GLightweightPeer.java.
	* gnu/java/awt/GLightweightPeer.java: Remove file.
	* gnu/java/awt/peer/GLightweightPeer.java: New file.
	* java/awt/Toolkit.java (createComponent): Return
	gnu.java.awt.peer.GLightweightPeer.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lightweight4.diff
Type: text/x-patch
Size: 9282 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20030813/6df6ee6d/attachment.bin>


More information about the Java-patches mailing list