Summary: | VerifyError when casting null to an array type | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.1 | ||
Target Milestone: | 2.1 M4 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Olivier Thomann
2002-11-21 16:38:24 EST
Almost the same pattern: class A { public static void main(String[] args) { try { int[][] tab; tab = null; tab[0] = new int[1]; } catch (NullPointerException e) { System.out.print("OK"); } } } With this code, all compilers (jikes, javac and eclipse) compile fine, but get a VerifyError at runtime. This second bug seems to be in SingleNameReference when generating the code for a local variable. We might want to add before the store call: if (assignment.expression.resolvedType == NullBinding && assignment.lhs.resolvedType.isArrayType()) { codeStream.checkcast(assignment.lhs.resolvedType); } // normal local assignment (since cannot store in outer local which are final locations) codeStream.store(localBinding, valueRequired); All kind of references would be affected by the same bug. Need to investigate. The problem is that these extra cast are only relevant when using local variables, not fields. Also, the first scenario is a read herring. The real issue is the second one. Solving the second will make the first one work fine as well. Fixed Verified. |