Bug 225563 - Class with compile errors results in invalid class file format
Summary: Class with compile errors results in invalid class file format
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-03 10:19 EDT by Markus Keller CLA
Modified: 2008-04-29 10:43 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (2.42 KB, patch)
2008-04-11 10:25 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-04-03 10:19:53 EDT
I20080401-0851

- new workspace
- paste to Package Explorer:

public class C implements None {
	public String toString(Arg a) {
		return null;
	}
	public String toString(Arg[] a) {
		return null;
	}
}

- create a second project
- add /_pasted_code_/bin to the build of the second project (Java Build Path > Libraries > Add Class Folder...)

- add a space to C and save
=> Warning in log:

Warning
Thu Apr 03 16:14:04 CEST 2008
The Java indexing could not index /_pasted_code_/bin/C.class. This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor
Comment 1 Olivier Thomann CLA 2008-04-03 10:31:46 EDT
I'll take care of this.
Comment 2 Olivier Thomann CLA 2008-04-11 09:56:32 EDT
Reproduced.
Comment 3 Olivier Thomann CLA 2008-04-11 10:02:15 EDT
The problem comes from the decoding of the missing types attribute.
I am working on it.
Comment 4 Olivier Thomann CLA 2008-04-11 10:20:40 EDT
The problem comes from the encoding of the attribute. When the same "unresolved" type shows up more than once, the missing types recorded in the .class file didn't match the number of unique entries and "0" was recorded in the .class file.
I wonder why the indexes are sorted. I don't see why this is useful.

Philippe, any clue on this ?
Comment 5 Olivier Thomann CLA 2008-04-11 10:25:28 EDT
Created attachment 95688 [details]
Proposed fix
Comment 6 Olivier Thomann CLA 2008-04-11 10:38:22 EDT
Released for 3.4M7.
Added regression test in org.eclipse.jdt.core.tests.builder.ErrorsTests#test0107.

Philippe, I kept the sorting of the indexes, but I don't really see why we need to do this.
Comment 7 Olivier Thomann CLA 2008-04-11 10:59:50 EDT
I remove the sorting of indexes as it doesn't change anything at the .class file level.
Comment 8 Olivier Thomann CLA 2008-04-11 11:40:10 EDT
In fact we don't need to resize since the iteration is done from 0 to numberOfMissingTypes when recording the indexes in the constant pool. The bug was the sorting of indexes which would put all the "0" indexes first.
The sorting is now removed and I added a comment to specify why we don't need to resize.
Comment 9 Philipe Mulet CLA 2008-04-11 12:01:25 EDT
Sorting is used to avoid producing structural changes on statement changes (where missing types would be inverted).
Comment 10 Olivier Thomann CLA 2008-04-11 12:39:36 EDT
Released a new version that ensures the missing type names are sorting according to their constant pool names.
Comment 11 Kent Johnson CLA 2008-04-29 10:43:32 EDT
Verified for 3.4M7 using I20080429-0100