Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-5
-
None
-
XP, Sun JDK 1.4.2_04
Description
I have taken a few days to study the various bugs that seemed to be associated with bad bytecode. The bugs fell under two groups:
1. Primitives used as function/closure parameters and local variables.
2. Scope introducing constructs in clsures, such as if, switch and while. Those constructs would generate inconsistent stack height.
Other related problems were
– +=
– return void from functions
– bad constructor bytecode for scripts
After some hair-pulling and losing time with JVM spec, disassemblers and decompilers, I believe most of these problems are gone with the patches attached here.
I also have created a test case that tests the above issues (see ClassGeneratorFixes.groovy)
Among the changes in the ClassGenerator are:
– reflowing the code to create fields.
– tuning the primitive types hanlding
– setting optionl attributes to generate better looking decompiled
code. (now I can get clean JAD decompiled source files with realtively simple groovy code)
– adding variables to localVariableTable to provide better debugging info in the bytecode.
– renaming some local variables to avoid warnings from compiler about hiding instance variables.
A couple of helper functions were added to related classes and the patches are in the attached patch files.
I have run all the changes through a full maven build and test (with the latest code from CVS HEAD) and came out clean.
Noticing that some of these bugs are really critical for releasing groovy as version 1, I thought I'd uploaded these patches for other developers to test them and imrpove them.
Thanks.