Community
Participate
Working Groups
Build ID: Build id: I20070625-1500 Steps To Reproduce: The Eclipse compiler reports the problem "Read access to enclosing field SyntheticAccessorTest.m_iPrivateCnt is emulated by a synthetic accessor method. Increasing its visibility will improve your performance" As the attached class suggests, there are no performance problems at all since modern (JIT) compilers seem to produce the same optimized code regardless of how the enclosing member is accessed. So there's no need to force people to violate good OOP practices in favour of gaining performance. More information: Use this test program D:\>java -version java version "1.6.0_05" Java(TM) SE Runtime Environment (build 1.6.0_05-b13) Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing javac -g:none performance/SyntheticAccessorTest.java java performance.SyntheticAccessorTest or java -XX:CompileThreshold=0 performance.SyntheticAccessorTest - - - - - - - - - - - - - - - - - - - - - - - - package performance; public final class SyntheticAccessorTest { private int m_iPrivateCnt; protected int m_iProtectedCnt; private SyntheticAccessorTest() {} public static void main(String[] args) { new SyntheticAccessorTest().run(1000000); Thread.yield(); long l_lPrivate = 0L; long l_lProtected = 0L; for (int i = 0; i < 100; i++) { final long[] l_result; l_result = new SyntheticAccessorTest().run(10000000); l_lPrivate += l_result[0]; l_lProtected += l_result[1]; } System.out.println("private: " + (l_lPrivate / 1000) + " us"); System.out.println("protected: " + (l_lProtected / 1000) + " us"); } private long[] run(final int p_iLoops) { final long l_lStartPrivate; final long l_lEndPrivate; final long l_lStartProtected; final long l_lEndProtected; // private m_iPrivateCnt = 0; l_lStartPrivate = System.nanoTime(); new Runnable() { @Override public void run() { for (int i = 0; i < p_iLoops; i++) m_iPrivateCnt++; } }.run(); l_lEndPrivate = System.nanoTime(); // protected m_iProtectedCnt = 0; l_lStartProtected = System.nanoTime(); new Runnable() { @Override public void run() { for (int i = 0; i < p_iLoops; i++) m_iProtectedCnt++; } }.run(); l_lEndProtected = System.nanoTime(); assert m_iProtectedCnt == p_iLoops; return new long[] {l_lEndPrivate - l_lStartPrivate, l_lEndProtected - l_lStartProtected}; } }
This is indeed true for speed nowadays, which is a good evolution. Still it makes class files bigger. I agree the error message sounds a bit too harsh, it should stop mentioning performance ramifications.
Also applications running in pure interpreted mode (no JIT) are slowed by such emulation
Created attachment 103466 [details] Proposed patch
Message catalog is not changeable before next release (for translation purpose).
If I understand your patch correctly, the warning messages were changed. From the standpoint of the compiler architects this may make sense. From an application programmer's point of view it is probably a useless warning. BTW, Eclipse's problems view will still be flooded with hundreds of synthetic accessor warnings. This makes switching between projects in the same workspace very slow and may hide more serious warnings. Unfortunately I could not find a switch to turn these warnings off. Please provide such a switch.
See preferences under: Java Compiler>Errors/Warnings>Code style>Access to non-accessible member of an enclosing type This warning is OFF by default.
Released message change for 3.5M1 Fixed
Verified for 3.5M1 using I20080805-1307