Bug 332744 - Generated model code doesn't compile with J2SE-1.4 execution environment
Summary: Generated model code doesn't compile with J2SE-1.4 execution environment
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-16 10:06 EST by Larry Isaacs CLA
Modified: 2011-01-25 10:39 EST (History)
3 users (show)

See Also:
amj87.iitr: review+


Attachments
Project that demonstrates the compile error. (81.67 KB, application/octet-stream)
2010-12-16 10:06 EST, Larry Isaacs CLA
no flags Details
junit tests (3.82 KB, patch)
2011-01-04 04:47 EST, Srikanth Sankaran CLA
no flags Details | Diff
Patch + test - under test (6.41 KB, patch)
2011-01-04 05:54 EST, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Isaacs CLA 2010-12-16 10:06:56 EST
Created attachment 185326 [details]
Project that demonstrates the compile error.

Starting this out at EMF mainly as a heads up since it is in generated model code that the compile errors occur.  However, this issue appears to originate with something that has changed in the JDT compiler at 3.7.  It's unclear whether the compiler has acquired a new bug or had one fixed.  I expect this bug will need to be transferred to JDT core to make this determination.

If you import the attached project in Eclipse 3.6, you will not see compile errors.  However, if you import it in Eclipse 3.7m4, there will be compile errors in the form of "Cannot cast from FeatureMap to InternalEList".  This occurs in the generated model code.  Key to the compile error is the J2SE-1.4 execution environment and the compiler compliance level matching that execution environment. If the compiler compliance level is changed from "1.4" to "1.5", the compile errors go away.

This project is a new plug-in project with the "servertype" model definition imported from the Web Tools Platform project with the same name.  The model code was generated, which created the Java files found under the "org.eclipse.jst.server.generic.servertype.definition" package.  I have verified that identical code is generated when using Eclipse + EMF for both 3.6.1 + 2.6.1 and 3.7m4 + 2.7.0m4.  The only difference is the compile errors when the compiler compliance level is "1.4" and Eclipse 3.7m4 is used.

To fix this issue in WTP, we'll be updating the project to J2SE-1.5 and the corresponding compiler compliance level.  As a result, WTP won't be depending on any particular outcome from this bug.
Comment 1 David Williams CLA 2010-12-16 10:33:10 EST
Just to reference the context, see also the discussion thread on our wtp-releng mailing list: 

http://dev.eclipse.org/mhonarc/lists/wtp-releng/msg08177.html 

(Thanks Larry).
Comment 2 Ed Merks CLA 2010-12-21 15:35:10 EST
I thought I'd already moved this to JDT.  This looks like a regression in M4.
Comment 3 Olivier Thomann CLA 2010-12-21 19:55:18 EST
Srikanth, please investigate.
Comment 4 Srikanth Sankaran CLA 2010-12-21 21:06:00 EST
Hello ! Can you please provide a self contained test case ?
The attached project references several extraneous packages
and types. I am having trouble fetching the referenced projects
to my workspace. If I use cvsroot/org.eclipse/www/modeling/emf
and cvsroot/org.eclipse/www/emf as the repository path as
mentioned in http://www.eclipse.org/projects/project_summary.php?projectid=modeling.emf, pserver aborts upon checkout.
Comment 5 Srikanth Sankaran CLA 2010-12-21 21:54:11 EST
Looks like that web page is out of date and the emf sources come
from /cvsroot/modeling. Even then I don't know what all I need
to download and what set up I should use. It shouldn't be that
hard to get a small stand alone test case outside of EMF that shows
this problem - Can you please attach one ? TIA.
Comment 6 Larry Isaacs CLA 2010-12-22 18:40:15 EST
I'm doubtful that I can successfully remove the "EMF" without disturbing the problem.  If you create a Target Platform using an Eclipse 3.7M4 SDK and an EMF + XSD 2.7.0M4a SDK, the project should have all of its dependencies satisfied.

For Windows, this target would use:

http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/S-3.7M4-201012081300/eclipse-SDK-3.7M4-win32.zip
http://www.eclipse.org/downloads/download.php?file=/modeling/emf/emf/downloads/drops/2.7.0/S201012150940/emf-xsd-SDK-2.7.0M4a.zip
Comment 7 Srikanth Sankaran CLA 2011-01-04 04:47:28 EST
Created attachment 185987 [details]
junit tests

(In reply to comment #6)
> I'm doubtful that I can successfully remove the "EMF" without disturbing the
> problem.  If you create a Target Platform using an Eclipse 3.7M4 SDK and an EMF
> + XSD 2.7.0M4a SDK, the project should have all of its dependencies satisfied.

Actually, producing a standalone test case was very straightforward,
nevertheless, thanks a lot for your instructions which were helpful.

Attached patch contains two junits one showing the behavior in 1.5 and
another in 1.4.
Comment 8 Srikanth Sankaran CLA 2011-01-04 05:54:19 EST
Created attachment 185993 [details]
Patch + test - under test
Comment 9 Srikanth Sankaran CLA 2011-01-10 01:10:25 EST
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=47074
In the code introduced to fix the bug mentioned above, we get
confused if one of the types is raw and the is parameterized
when we check if co-variance is being employed. We should look
at the original methods in both cases for 1.4-, which is what
we do with the current patch.

Ayush, please review, TIA.
Comment 10 Srikanth Sankaran CLA 2011-01-17 03:05:37 EST
Released in HEAD for 3.7 M5.
Comment 11 Ayushman Jain CLA 2011-01-18 10:12:32 EST
Looks good.
Comment 12 Olivier Thomann CLA 2011-01-25 10:39:45 EST
Verified for 3.7M5 using I20110124-1800