Bug 120223 - [compiler] Support for "-target cldc1.1"
Summary: [compiler] Support for "-target cldc1.1"
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.4 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL: http://java.sun.com/j2se/1.5.0/docs/t...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-10 07:33 EST by Nils Hammar CLA
Modified: 2007-10-23 10:04 EDT (History)
4 users (show)

See Also:


Attachments
Proposed fix (69.97 KB, patch)
2007-09-13 12:53 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (72.75 KB, patch)
2007-09-13 13:47 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 Nils Hammar CLA 2005-12-10 07:33:10 EST
Suns Java 1.5 compiler has an option "-target cldc1.0", which should be supported by Eclipse.

See: http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html#crosscomp-options

This option is useful when doing builds for a J2ME environment.
Comment 1 Olivier Thomann CLA 2005-12-13 10:57:48 EST
This is not the same stack map table attribute than the one for 1.6. I need to find the specs in order to know if the support for 1.6 could be tweaked to generate the attribute for cldc1.0.
Comment 2 Olivier Thomann CLA 2005-12-14 11:03:48 EST
I got access to the cldc1.0 specs and the StackMap attribute in cldc is different from the StackMapTable attribute in 1.6.
They have some similarities, but it would required a specific handling. The data collected for the generation of the stack map table attribute should be sufficient to generate the stack map attribute.
Comment 3 Olivier Thomann CLA 2005-12-14 12:38:43 EST
Also cldc target should inline jsrs.
Comment 4 Philipe Mulet CLA 2006-03-27 08:09:54 EST
Should also check whether floating point is allowed there.
Comment 5 Philipe Mulet CLA 2006-03-27 08:10:24 EST
Not for 3.2, but maybe 3.3
Comment 6 Ken Walker CLA 2006-03-28 11:27:02 EST
Floating point is supported on CLDC 1.1
Comment 7 Nils Hammar CLA 2006-12-15 13:47:50 EST
Strange enough - the cldc1.0 target option has disappeared from javac!

The option is no longer present in the 1.5 documentation and javac for Java 6 no longer accepts the option.

Anybody got a clue on WHY this has been dropped?
Comment 8 Philipe Mulet CLA 2007-08-29 04:44:20 EDT
reopening for consideration during 3.4 cycle
Comment 9 Jerome Lanneluc CLA 2007-09-12 09:19:11 EDT
We'll start by supporting CLDC1.1 first (updated title accordingly). And if needed we can try later on to support CLDC1.0.
Comment 10 Nils Hammar CLA 2007-09-13 01:51:48 EDT
(In reply to comment #9)
> We'll start by supporting CLDC1.1 first (updated title accordingly). And if
> needed we can try later on to support CLDC1.0.
> 

That's fine with me.
Comment 11 Philipe Mulet CLA 2007-09-13 07:08:05 EDT
The only difference from compiler standpoint between cldc1.0 and cldc1.1 is that floating point operations should be forbidden in cldc1.0. It is unclear whether we want to put in place a specific control on the compiler, or rather rely on users to restrain themselves. The latter seems to be fairly tolerated by users.

So until this becomes an issue, we can safely claim cldc1.1 compliance. 
This being said, we could still want cldc1.0 target, to stamp the classfiles accordingly (still not rejecting floating point operations).
Comment 12 Olivier Thomann CLA 2007-09-13 12:53:44 EDT
Created attachment 78342 [details]
Proposed fix

This patch adds cldc stack generation in the batch compiler when the target -cldc1.1 is used.
It also automatically inlines the jsrs.
I'll release it for 3.4M2. I keep this bug opened till we figure out if this is enough.
Comment 13 Olivier Thomann CLA 2007-09-13 13:02:57 EDT
Of course to get the same support in Eclipse, the UI needs to be updated.

Does it sound reasonable to limit the source version to 1.3 and the compliance version to 1.3?
I don't see the point of having source 1.4 if assert statement cannot be supported (java.lang.AssertionError doesn't seem to be part of the cldc1.1 classes).
Therefore it would be consistent to keep the compliance also to 1.3.
Any thoughts?
Comment 14 Olivier Thomann CLA 2007-09-13 13:17:39 EDT
We might want to be able to use compliance 1.4 since this is not incompatible with source 1.3. Technically speaking I am not sure that the compliance really matters, but I don't see the point of allowing 1.5 or above.
Comment 15 Olivier Thomann CLA 2007-09-13 13:36:23 EDT
It seems that we could remove the generation of these attributes (Synthetic, SourceFile, LineNumberTable, LocalVariableTable and Deprecated) since these attributes don't need to be handled by a CLDC implementation.
Comment 16 Olivier Thomann CLA 2007-09-13 13:47:39 EDT
Created attachment 78358 [details]
Proposed fix

Patch released for 3.4M2. It contains the new constant VERSION_CLDC_1_1 in org.eclipse.jdt.core.JavaCore that will allow the UI to update the compiler preference page.
Comment 17 Nils Hammar CLA 2007-09-14 01:36:22 EDT
(In reply to comment #14)
> We might want to be able to use compliance 1.4 since this is not incompatible
> with source 1.3. Technically speaking I am not sure that the compliance really
> matters, but I don't see the point of allowing 1.5 or above.
> 

Personally I would like to see the support for 1.5 due to the existence of generics (which is a really good thing considering avoidance of unnecessary bugs), but there may be other problems around that too.
Comment 18 Olivier Thomann CLA 2007-09-14 08:36:12 EDT
(In reply to comment #17)
> Personally I would like to see the support for 1.5 due to the existence of
> generics (which is a really good thing considering avoidance of unnecessary
> bugs), but there may be other problems around that too.
I don't really understand the reason why 1.5 should be considered.
1) The cldc libraries don't contain generic types. I guess this is the case.
2) Since the compilation should be done with cldc libraries on the classpath, the compiler won't like the fact that generics are used if the libraries are not generics.
For example,
import java.util.Hashtable;

public class X {
        public static Hashtable<String> context;
}

ends up with this error when cldc1.1 libraries are used to compile the code.
----------
1. ERROR in D:\tests_sources\X.java (at line 4)
	public static Hashtable<String> context;
	              ^^^^^^^^^
The type Hashtable is not generic; it cannot be parameterized with arguments <String>
----------
1 problem (1 error)

A cldc1.1 implementation is supposed to be able to "read" .class files up to 1.4 target. I haven't read anything related to the java.lang.AssertionError not being present in cldc1.1 libraries. I don't see how 1.4 code that uses assertions could be run on a cldc1.1 implementation. I don't have a reference platform to try it.

Do you still believe that 1.5 should be supported?
Comment 19 Philipe Mulet CLA 2007-10-23 05:40:48 EDT
The request in comment 17 sounds similar to allowing compiling 1.5 sources for 1.4 targets (-target jsr14). This is a separate issue to pure CLDC 1.1 output which is the goal of this bug report.

As said, CLDC1.1 libraries are not generic today, and not using Java5 sources.

I recommend closing this bug as fixed, and leaving 1.5 concerns to a separate (new) bug.
Comment 20 Nils Hammar CLA 2007-10-23 07:07:49 EDT
OK(In reply to comment #19)
> The request in comment 17 sounds similar to allowing compiling 1.5 sources for
> 1.4 targets (-target jsr14). This is a separate issue to pure CLDC 1.1 output
> which is the goal of this bug report.
> 
> As said, CLDC1.1 libraries are not generic today, and not using Java5 sources.
> 
> I recommend closing this bug as fixed, and leaving 1.5 concerns to a separate
> (new) bug.
> 

OK
Comment 21 Olivier Thomann CLA 2007-10-23 10:04:22 EDT
Released for 3.34M2.
Comment 22 Olivier Thomann CLA 2007-10-23 10:04:53 EDT
Verified with 3.2M4.