Bug 167811 - Java compiler sporadically can not resolve valid variable names
Summary: Java compiler sporadically can not resolve valid variable names
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-12-13 03:28 EST by Oleksandr Alesinskyy CLA
Modified: 2009-08-30 02:07 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksandr Alesinskyy CLA 2006-12-13 03:28:28 EST
Hello,

sometimes compiler can not resolve absolutely valid references to variable names, mostly references from anonymous nested classes to final local variables of containing method. Behavior is stohastic - e.g. reference to variable in one line of code is properly resolved and in next line compiler complains on the same variable name. E.g.
final SomeClass var1;
ui.addActionListener(ACTION,new ActionListener() {
    public void actionPerformed(ActionEvent ev) {
        .................
        var1 = something;
        if ("".equals(var1.someMethod()) { ... }
}

First reference to var1 inside actionPerformed is accepted, on second one causes compiler error "var1 can not be resolved".

Cleaning of project or dummy editing does not help, but some small reordering of lines of code in the nested class, or assigning a result of var1.someMethod()) to intermediary variable and use of this variable in the "if" does help.

I have met this problems several times last week. Never have met it before (so it may be attributed to recent updates). Build id: M20060921-0945

Regards,
Oleksandr Alesinskyy
Comment 1 Olivier Thomann CLA 2006-12-13 08:59:38 EST
Could you please provide a complete test case with your compiler settings?
Thanks.
Comment 2 Philipe Mulet CLA 2006-12-13 09:25:01 EST
Never heard about this. Without steps, there is little hope we can do anything.
Comment 3 Oleksandr Alesinskyy CLA 2006-12-13 09:57:51 EST
I'm unable to provide test case as it is unstable and minor tweaking of source code resolves it and it is (almost) impossible to produce isolated test case.

Settings:

/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance=1.5
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source=1.5
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5

Hope it would help,

Regards,
Oleksandr
Comment 4 Philipe Mulet CLA 2006-12-13 10:11:26 EST
May be related to bug 167750
Comment 5 Olivier Thomann CLA 2006-12-15 14:07:03 EST
(In reply to comment #3)
> I'm unable to provide test case as it is unstable and minor tweaking of source
> code resolves it and it is (almost) impossible to produce isolated test case.
If you have a test case (even a big one) that reproduces the issue, please provide it. Without a test case, there is absolutely nothing we can do.
Closing as REMIND.
Reopen once a test case is provided.
Comment 6 Oleksandr Alesinskyy CLA 2006-12-15 17:25:43 EST
I would try, but I'm not sure if I would succeed. The problem is that I may not provide the whole project, as it strictly prohibited by company rules, and any try to isolate a case results in a disappearing of the effect.
Comment 7 Denis Roy CLA 2009-08-30 02:07:11 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.