User account creation filtered due to spam.

Bug 19677 - invalid "may not have been initialized" error
Summary: invalid "may not have been initialized" error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, rejects-valid
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2005-01-28 19:21 UTC by Jerry Haltom
Modified: 2007-01-09 20:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-01 02:37:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerry Haltom 2005-01-28 19:21:52 UTC
Following Eclipse code snippet that fails:

protected void join(InternalJob job) {
	final IJobChangeListener listener;

	synchronized (lock) {
		listener = new JobChangeAdapter() {
			public void done(IJobChangeEvent event) {
				barrier.release();
			}
		};
		job.addJobChangeListener(listener);
	}
}

The error reports the line containing listener = as the problem.
Comment 1 Jerry Haltom 2005-01-28 19:23:53 UTC
Oh yes, of course:

runtime.jar:
    [mkdir] Created dir:
/tmp/ram/eclipse-3.0.1/source-tree/plugins/org.eclipse.core.runtime/temp.folder/runtime.jar.bin
    [javac] Compiling 158 source files to
/tmp/ram/eclipse-3.0.1/source-tree/plugins/org.eclipse.core.runtime/temp.folder/runtime.jar.bin
    [javac]
/tmp/ram/eclipse-3.0.1/source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/JobManager.java:
In class `org.eclipse.core.internal.jobs.JobManager':
    [javac]
/tmp/ram/eclipse-3.0.1/source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/JobManager.java:
In method
`org.eclipse.core.internal.jobs.JobManager.join(org.eclipse.core.internal.jobs.InternalJob)':
    [javac]
/tmp/ram/eclipse-3.0.1/source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/JobManager.java:548:
error: Variable `listener' may not have been initialized.
    [javac]                     };
    [javac]    ^
    [javac] 1 error
Comment 2 Andrew Pinski 2005-01-28 19:35:32 UTC
Confirmed, reduced to:
class a1 { public int f(){return 1;} }
class t
{
  Object f;
  void g(a1 a)  {}
  void f()
  {
    final a1 a;
    a = new a1 () { public int f(){return 0;}};
    g(a);
  }
}
Comment 3 Andrew Pinski 2005-01-28 19:43:06 UTC
Related to bug 16839.  The problem might be the same problem after all because final are collected for 
anonymous inner classes.
Comment 4 Tom Tromey 2005-01-30 19:02:56 UTC
Yes, the underlying problem is the same as with bug 16839.
gcj captures all 'final' local variables in an anonymous class.
This is incorrect -- it should only capture those which are actually
used.
Comment 5 Tom Tromey 2007-01-09 20:46:59 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.