Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [jdt-dev] Read access to enclosing field is emulated by a syn thetic accesso r method. Increasing its visibility will improve your pe r f ormance

Title: RE: [jdt-dev] Read access to enclosing field is emulated by a syn thetic accesso r method. Increasing its visibility will improve your per f ormance

Olivier,

Thanks for the quick reply.

I am discussing whether or not we should code to remove these warnings with folks on the Apache Jakarta Commons Dev mailing list. The current questions I get back are:

        "Small Q: Are these really compiler warnings, or due to some plugin in eclipse? i.e. are the performance implications due to java specs, or a particular jvm implementation etc."

        "I don't see a problem here because the code compiles and works.  This
warning shouldn't be the sole basis for making fields more visible."

        "Moreover, this "warning" is suggesting that we change the level of visibility here.  This is more than style, changing from private to protected is a semantic difference."

I took a look at the JLS and JVM specs but could not find the behavior described ("a method invocation each time you access the member at runtime").

Could you give me an 'official' Java reference in a spec on this?

Thank you,
Gary

-----Original Message-----
From: Olivier Thomann [mailto:Olivier_Thomann@xxxxxxxxxx]
Sent: Tuesday, April 22, 2003 1:15 PM
To: jdt-dev@xxxxxxxxxxx
Subject: RE: [jdt-dev] Read access to enclosing field is emulated by a syn thetic accesso r method. Increasing its visibility will improve your per f ormance

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.

HTH,

Olivier



                                                                                                                                                   

                      Gary Gregory                                                                                                                 

                      <ggregory@seagull        To:       "'jdt-dev@xxxxxxxxxxx'" <jdt-dev@xxxxxxxxxxx>                                             

                      sw.com>                  cc:                                                                                                 

                      Sent by:                 Subject:  RE: [jdt-dev] Read access to enclosing field is emulated by a syn        thetic accesso r 

                      jdt-dev-admin@ecl         method. Increasing its visibility will improve your per  f ormance                                 

                      ipse.org                                                                                                                     

                                                                                                                                                   

                                                                                                                                                   

                      04/22/03 02:12 PM                                                                                                            

                      Please respond to                                                                                                            

                      jdt-dev                                                                                                                      

                                                                                                                                                   

                                                                                                                                                   




Could anyone comment on what this compiler warning and its performance
implication is all about?


Read access to enclosing field GenericObjectPool._evictionCursor is
emulated by a synthetic accessor method. Increasing its visibility will
improve your performance


Thank you,


Gary


-----Original Message-----
From: Gary Gregory [mailto:ggregory@xxxxxxxxxxxxx]
Sent: Friday, March 21, 2003 9:25 AM
To: 'jdt-dev@xxxxxxxxxxx'
Subject: RE: [jdt-dev] Read access to enclosing field is emulated by a syn
thetic accesso r method. Increasing its visibility will improve your perf
ormance


So sorry! Mille sabords! Je m'excuse.
Gary
-----Original Message-----
From: Jerome Lanneluc [mailto:jerome_lanneluc@xxxxxxxxxx]
Sent: Friday, March 21, 2003 3:24 AM
To: jdt-dev@xxxxxxxxxxx
Subject: Re: [jdt-dev] Read access to enclosing field is emulated by a
synthetic accesso r method. Increasing its visibility will improve your
performance


Gary,
You didn't attach your test case class.
Jerome


|---------+---------------------------->
|         |           Gary Gregory     |
|         |           <ggregory@seagull|
|         |           sw.com>          |
|         |           Sent by:         |
|         |           jdt-dev-admin@ecl|
|         |           ipse.org         |
|         |                            |
|         |                            |
|         |           03/21/2003 01:07 |
|         |           AM               |
|         |           Please respond to|
|         |           jdt-dev          |
|         |                            |
|---------+---------------------------->
  >
------------------------------------------------------------------------------------------------------------------------|



|                                                                                                                       




  |       To:       "'jdt-dev@xxxxxxxxxxx'" <jdt-dev@xxxxxxxxxxx>
|


  |       cc:
|


  |       Subject:  [jdt-dev] Read access to enclosing field is emulated by
a synthetic accesso r method. Increasing its   |


  |        visibility will improve your performance
|



|                                                                                                                       




  >
------------------------------------------------------------------------------------------------------------------------|





Hello All,


In some code I get eclipse compiler warnings like:


Read access to enclosing field GenericObjectPool._evictionCursor is
emulated by a synthetic accessor method. Increasing its visibility will
improve your performance    GenericObjectPool.java  Jakarta
Commons/pool/src/java/org/apache/commons/pool/impl      line 1005


I have created the attached test in order to see what improvements we are
talking about. I tried to make the test as simple as possible. On the JRE
1.4.1, sometimes but not always, using "a synthetic accessor method" is
slower, sometimes faster. Can you explain what is going on here? On JRE
1.3.1, the synthetic version is always slower (good). Can this be explained

away by GC? Or some other internal process?


Thank you,
Gary


Eclipse Platform
Version: 2.1.0
Build id: 200303071024


Test results:


Running Java 1.3.1_07-b02 on Windows XP 5.1 null


iterations = 1000
withWarningMsecs = 0
noWarningMsecs = 0
no difference


iterations = 10000
withWarningMsecs = 10
noWarningMsecs = 0
no warning class is faster by 10 msecs


iterations = 100000
withWarningMsecs = 10
noWarningMsecs = 0
no warning class is faster by 10 msecs


iterations = 1000000
withWarningMsecs = 30
noWarningMsecs = 20
no warning class is faster by 10 msecs


iterations = 10000000
withWarningMsecs = 290
noWarningMsecs = 241
no warning class is faster by 49 msecs


iterations = 100000000
withWarningMsecs = 2663
noWarningMsecs = 2354
no warning class is faster by 309 msecs


Done.


----------------------------------------------------------


Running Java 1.4.1_02-b06 on Windows XP 5.1 Service Pack 1


iterations = 1000
withWarningMsecs = 10
noWarningMsecs = 0
no warning class is faster by 10 msecs


iterations = 10000
withWarningMsecs = 0
noWarningMsecs = 0
no difference


iterations = 100000
withWarningMsecs = 10
noWarningMsecs = 10
no difference


iterations = 1000000
withWarningMsecs = 90
noWarningMsecs = 90
no difference


iterations = 10000000
withWarningMsecs = 811
noWarningMsecs = 821
no warning class is SLOWER by 10 msecs


iterations = 100000000
withWarningMsecs = 8152
noWarningMsecs = 8092
no warning class is faster by 60 msecs


Done.









_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-dev







_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-dev


Back to the top