Bug 37387

Summary: Compiler generates unnecessary byte codes
Product: [Eclipse Project] JDT Reporter: Andreas Winter <andreas.winter>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andreas.winter
Version: 2.1   
Target Milestone: 2.1.1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Fix proposal none

Description Andreas Winter CLA 2003-05-08 10:39:53 EDT
Compiling 
   private static final Object X[] = new Object[]{null,null}
yields much longer byte code in Eclipse 2.1.1 (200305071103) than in 2.0.2
(200211071448).
The compiler generates unnecessary stores for the null values.
Comment 1 Olivier Thomann CLA 2003-05-08 12:55:11 EDT
The reason is that we no longer consider null has a constant. This case could
still be optimized. I will investigate.
Comment 2 Olivier Thomann CLA 2003-05-08 13:04:05 EDT
Created attachment 4825 [details]
Fix proposal

Philippe, I attached a patch that optimizes this case. We now generate the same
bytecodes than jikes. javac 1.4.1_02 or 1.4.2b21 still generate the whole array
initializer. Let me know if you want me to release it.
Comment 3 Philipe Mulet CLA 2003-05-12 06:04:35 EDT
Please release this patch. Indeed, I forgot about this codegen optimization 
when removing null constant expressions.
Comment 4 Philipe Mulet CLA 2003-05-12 06:04:59 EDT
Olivier, also backport it to 2.1 maintenance stream.
Comment 5 Olivier Thomann CLA 2003-05-12 10:45:11 EDT
Fixed and released in HEAD stream.
Comment 6 Olivier Thomann CLA 2003-05-12 10:55:12 EDT
Backported to 2.1 maintenance stream.
Comment 7 Olivier Thomann CLA 2003-05-12 11:39:57 EDT
Regression test added.
Comment 8 David Audel CLA 2003-06-06 07:02:28 EDT
Verified.