Summary: | Build problems when instance variable name matches constructor parameter name and assignment to this.name in try block | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Kevin J. Grittner <kjgrittn> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | minor | ||
Priority: | P1 | ||
Version: | 2.0 | ||
Target Milestone: | 2.0 M2 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Kevin J. Grittner
2002-01-10 14:54:26 EST
Excellent find. Problem comes from the fact that (parsed) field references do not set the FIELD bit (as other name references do). As a result, the flow analysis is fooled into thinking it is dealing with a local variable. As a work-around, you can rename your argument, and assign the field without using the syntax 'this.name', but simply name. public final class TableData { public final String name; public TableData(String initName) { try {} finally { name = initName; } } } Will be fixed in next integration build. Not fixed in 1.0. Running ConformTest.test110, I got: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.FieldReference at org.eclipse.jdt.internal.compiler.flow.FinallyFlowContext.complainOnRedundantFinalAssignments(FinallyFlowContext.java:33) at org.eclipse.jdt.internal.compiler.ast.TryStatement.analyseCode(TryStatement.java:132) at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.analyseCode(ConstructorDeclaration.java:54) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:359) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:67) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:379) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:202) at org.eclipse.jdt.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:129) at org.eclipse.jdt.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:114) at org.eclipse.jdt.tests.compiler.regression.ConformTest.test110(ConformTest.java:3317) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestDecorator.run(TestDecorator.java:28) at org.eclipse.jdt.tests.compiler.regression.RegressionTestSetup.run(RegressionTestSetup.java:38) Fix was incomplete, revised fix (for both 1.0 and 2.0), added regresion test for both streams. Verified in rollup2. |