commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <GGreg...@seagullsoftware.com>
Subject RE: svn commit: r620651 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Date Mon, 11 Feb 2008 23:22:09 GMT
Hi Phil:

By definition, when a class element is private, it cannot be seen from outside the scope of
the type that defines it. The compiler treats inner classes with some special processing though.

Here is Olivier Thomann's explanation [1]:

"You get this warning as soon as you access a private member (fields or
methods) of the enclosing class inside an inner class (anonymous, local or
member classes).

The compiler uses a static access method to access the private member in
order to workaround the VM access violation. You cannot access directly a
private member from another class. From the VM point of view, an inner
class is a different class and has no relation with its enclosing class.

So doing this access to a private member you pay the price of a method
invocation each time you access the member at runtime. This is not the case
if the member is package visible."

Gary

[1] http://dev.eclipse.org/mhonarc/lists/jdt-dev/msg00145.html

> -----Original Message-----
> From: Phil Steitz [mailto:phil.steitz@gmail.com]
> Sent: Monday, February 11, 2008 3:04 PM
> To: dev@commons.apache.org
> Subject: Re: svn commit: r620651 -
> /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/Generi
> cKeyedObjectPool.java
>
> I would like to understand exactly what performance improvment results
> from this change - i.e., see some microbenchmarks or other
> explanation.
>
> Making this protected adds it to the API that we are committing to
> maintain and I do not want to do this unless it really helps
> performance.
>
> Phil
>
> On 2/11/08, ggregory@apache.org <ggregory@apache.org> wrote:
> > Author: ggregory
> > Date: Mon Feb 11 14:34:34 2008
> > New Revision: 620651
> >
> > URL: http://svn.apache.org/viewvc?rev=620651&view=rev
> > Log:
> > Fix compiler warning: Access to enclosing constructor
> GenericKeyedObjectPool.ObjectQueue() is emulated by a synthetic accessor
> method. Increasing its visibility will improve your performance
> >
> > Modified:
> >
> commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/Generic
> KeyedObjectPool.java
> >
> > Modified:
> commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/Generic
> KeyedObjectPool.java
> > URL:
> http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apach
> e/commons/pool/impl/GenericKeyedObjectPool.java?rev=620651&r1=620650&r2=
> 620651&view=diff
> >
> ======================================================================
> ========
> > ---
> commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/Generic
> KeyedObjectPool.java (original)
> > +++
> commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/Generic
> KeyedObjectPool.java Mon Feb 11 14:34:34 2008
> > @@ -1681,7 +1681,7 @@
> >     /**
> >      * A "struct" that keeps additional information about the actual queue of
> pooled objects.
> >      */
> > -    private class ObjectQueue {
> > +    protected class ObjectQueue {
> >         private int activeCount = 0;
> >         private final CursorableLinkedList queue = new CursorableLinkedList();
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message