This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 9781 - fastjavac-inner class member variable initializers are performed twice
Summary: fastjavac-inner class member variable initializers are performed twice
Status: CLOSED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: -FFJ-
Hardware: PC All
: P2 blocker (vote)
Assignee: Ivan Bradac
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-02-22 16:07 UTC by Martin Grebac
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Grebac 2001-02-22 16:07:49 UTC
A test class follows:

public class innerTest {

	private inner1 m_inner = null;
	private hi     m_hi = new hi( "innerTest - (variable init)" );

    // Our little test inner class..
	private class inner1
	{
		// We expect this to happen once, *before* inner1's constructor is executed..
		private hi m_hi = new hi( "inner1 - (variable init)" );

		private inner1()
		{
			// This should overwrite the instance created by the initializer..
			m_hi = new hi( "inner1 - (constructor)" );
		}
	}

	public innerTest()
	{
		// Construct a "hi" to ensure this doesn't happen for outer classes.
		m_hi = new hi( "innerTest - (constructor)" );

		// Test inner classes..
		m_inner = new inner1();
	}

	public static void main( String args[] )
	{
		new innerTest();
	}
}

/** The little class we use to say "hi" */
class hi
{
	hi( String msg )
	{
		System.out.println( msg + " has been initialised!" );
	}
}

When this is compiled and run; you would expect the following output on standard
out:

innerTest - (variable init) has been initialised!
innerTest - (constructor) has been initialised!
inner1 - (variable init) has been initialised!
inner1 - (constructor) has been initialised!

and it is what you get with javac.

However; when compiled with the FFJ V2.0 fastjavac you get the following:

innerTest - (variable init) has been initialised!
innerTest - (constructor) has been initialised!
inner1 - (variable init) has been initialised!
inner1 - (constructor) has been initialised!
inner1 - (variable init) has been initialised!

As you can see - the member variable initialization for the "inner1" class has
occurred twice, once before construction and then once after. I believe this is
*not* correct.
Comment 1 Svata Dedic 2001-02-22 18:12:00 UTC
Verified in fastjavac #524 -- this is a *critical* one because the bug does not
result in any kind of RuntimeException or Error, but may corrupt data of the
user program.
Comment 2 Ivan Bradac 2001-02-23 18:28:40 UTC
Has been forwarded to the Sun's fastjavac team.
Comment 3 Ivan Bradac 2001-04-19 10:36:37 UTC
Fixed in dev and maintrunk
Comment 4 Ivan Bradac 2001-04-19 10:37:45 UTC
Fixed in dev and maintrunk.
Comment 5 Jan Becicka 2001-04-26 10:44:30 UTC
[NB3.2.38] Verified (fastjavac #525)
Comment 6 Quality Engineering 2003-07-01 13:19:53 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.