Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 8741 invoked from network); 16 Mar 2006 14:33:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Mar 2006 14:33:49 -0000 Received: (qmail 4441 invoked by uid 500); 16 Mar 2006 14:33:41 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 4357 invoked by uid 500); 16 Mar 2006 14:33:41 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 4339 invoked by uid 99); 16 Mar 2006 14:33:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Mar 2006 06:33:41 -0800 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 202.81.18.152 is neither permitted nor denied by domain of richard.liangyx@gmail.com) Received: from [202.81.18.152] (HELO ausmtp04.au.ibm.com) (202.81.18.152) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Mar 2006 06:33:37 -0800 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp04.au.ibm.com (8.12.10/8.13.5) with ESMTP id k2GEfAQ8108754 for ; Fri, 17 Mar 2006 01:41:10 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.250.244]) by sd0208e0.au.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k2GEaWf2245952 for ; Fri, 17 Mar 2006 01:36:32 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.12.11/8.13.3) with ESMTP id k2GEXCc6003043 for ; Fri, 17 Mar 2006 01:33:12 +1100 Received: from d23m0011.cn.ibm.com (d23m0011.cn.ibm.com [9.181.32.74]) by d23av03.au.ibm.com (8.12.11/8.12.11) with ESMTP id k2GEX99o003017 for ; Fri, 17 Mar 2006 01:33:10 +1100 Received: from [127.0.0.1] ([9.65.74.101]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.53HF294) with ESMTP id 2006031622330273-5788 ; Thu, 16 Mar 2006 22:33:02 +0800 Message-ID: <441976DF.8010800@gmail.com> Date: Thu, 16 Mar 2006 22:31:59 +0800 From: Richard Liang Organization: IBM China Software Development Lab User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: Solution for 5.0 language features in Eclipse(Re: And enum types (Re: API with generics)) References: <003b01c647d6$2f52b240$1101a8c0@LITTLEGUY> <4417C47F.4070306@gmail.com> <906dd82e0603150152y219c3a61q@mail.gmail.com> <44192E2F.8050506@gmail.com> <4419738E.9010704@googlemail.com> In-Reply-To: <4419738E.9010704@googlemail.com> X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.53HF294 | January 28, 2005) at 16/03/2006 22:33:08, Serialize by Router on D23M0011/23/M/IBM(Release 6.53HF294 | January 28, 2005) at 16/03/2006 22:33:09, Serialize complete at 16/03/2006 22:33:09 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N That's great, Paulex. Then we can implement Java 5 language features for Harmony. Oliver Deakin wrote: > Paulex Yang wrote: >> Hi, >> >> I just find a way to use Java 5 language features in Eclipse. You can >> set "Compiler compliance level" to 5.0, but set "Generated .class >> files compatibility " to 1.4. So that most Java 5 language new >> features can be used, but the class file still can run on HarmonyVM! >> > > That's great! I was suspicious that this would probably not work using > the javac provided with IBMs JDK, so I gave it a try: > > >javac -source 1.5 -target 1.4 Java5Test.java > javac: source release 1.5 requires target release 1.5 > > A little searching about turned up a message [1] in the Gump mail > archive that suggests using the "-target jsr14" option to compile > 1.5 code into 1.4 compatible bytecodes. Attempting to compile > Java5Test.java with this option completes successfully. > Having added your mocked-up Enum class to luni.jar I was able to run > Java5Test against Harmony code. > > Similar options can be passed to the Ant javac task: > > > > Regards, > Oliver > > [1] > http://mail-archives.apache.org/mod_mbox/gump-general/200407.mbox/%3c40E5728E.70109@gmx.de%3e > > > >> At least 6 Java 5 features can be used in this way, because they all >> don't need enhance class file (in same reason, I don't expect >> annotation can be used): >> generics >> enhance for loop >> enum >> static import >> auto boxing/unboxing >> varargs >> >> I've tested the 6 Java 5 language features in the little test below, >> and this class can run HarmonyVM smoothly. Only one modification >> needed, you should add a java.lang.Enum implementation to LUNI >> component, I've attached a naive impl of Enum below, too. >> >> But I haven't investigated the Eclipse compiler document yet to find >> what's the options should be set in command line, so that the Ant as >> well as Harmony build system can work in this way. If this is >> feasible, we can free from Java 1.4 jail! >> >> >> import static java.util.Locale.US; >> >> import java.util.ArrayList; >> import java.util.HashMap; >> import java.util.List; >> >> public class Java5Test { >> public static void main(String[] args) { >> List slist = new ArrayList(); >> slist.add("generics and enhance for loop test"); >> for(String s: slist){ >> System.out.println(s); >> } >> System.out.println(EnumTest.enum1); >> variArgs(1,2,3); >> System.out.println("static import test:"+US); >> HashMap map = new HashMap(); >> map.put(1, "value1"); >> System.out.println("auto boxing/unboxing test:"+map.get(1)); >> } >> enum EnumTest{ >> enum1, enum2, enum3 >> } >> public static void variArgs(int... i){ >> System.out.println("variable args test"); >> } >> } >> >> >> >> package java.lang; >> >> public class Enum { >> public Enum(String name, int ordinal){ >> } >> } >> >> >> Mikhail Loenko wrote: >>> Hi Paulex, >>> >>> We also had problem with enums while developing security package. >>> Finally, we made it 1.5 compliant, tested with BEA 1.5 and commented >>> out >>> >>> See >>> modules/security/src/common/javasrc/java/security/KeyRep.java >>> >>> Thanks, >>> Mikhail >>> >>> 2006/3/15, Paulex Yang : >>> >>>> Nathan Beyer wrote: >>>> >>>>> My approach has been to make the APIs as close to possible as the >>>>> Java 5 >>>>> spec >>>>> >>>> Agree. Another issue is enum, for example, >>>> >>>> public enum SomeEnum{ >>>> enum1, enum2, enum3 >>>> } >>>> >>>> I think the mimic will look like: >>>> >>>> public final class SomeEnum extends Enum{ >>>> public static final SomeEnum enum1 = new SomeEnum("enum1", 0); >>>> public static final SomeEnum enum2 = new SomeEnum("enum2", 1); >>>> public static final SomeEnum enum3 = new SomeEnum("enum3", 2); >>>> >>>> protected SomeEnum(String name, int |ordinal|){ >>>> super(name, ordinal). >>>> } >>>> } >>>> >>>> and of course, the abstract class Enum(declaration without generics of >>>> course) must exist at first. >>>> >>>> Thoughts? I will raise a jira about Enum abstract class and create a >>>> patch later to support this mimic if this approach is fine. >>>> >>>>> and then leave //TODO comments about what needs to be added and >>>>> what is >>>>> needed to fix it or what is preventing completion. >>>>> >>>>> The same condition applies to annotations and methods that take >>>>> advantage of >>>>> return type covariance. >>>>> >>>>> We could consider creating a comment practice to flag specific >>>>> changes. >>>>> Perhaps something like this: >>>>> >>>>> //HARMONY_GENERICS comment >>>>> //HARMONY_ANNOTATION @annotation comment >>>>> //HARMONY_COVARIANT_RETURN Type comment >>>>> >>>>> In Eclipse's Java editor you can add special meaning to comments of a >>>>> certain format, so this could be taken advantage of there at least. >>>>> >>>>> -Nathan >>>>> >>>>> -----Original Message----- >>>>> From: karan malhi [mailto:karan.malhi@gmail.com] >>>>> Sent: Tuesday, March 14, 2006 8:04 PM >>>>> To: harmony-dev@incubator.apache.org >>>>> Subject: API with generics >>>>> >>>>> Hi, >>>>> >>>>> I might have missed out on it in earlier discussions so please >>>>> excuse me >>>>> for my ignorance. What is the strategy of harmony with regards to >>>>> Generics? To be more specific, I am right now implementing the >>>>> javax.accessibility.AccessibleStateSet class which has a protected >>>>> variable with the following signature: >>>>> >>>>> protected Vector states >>>>> >>>>> My understanding is that currently generics are not supported. What >>>>> should I do in this case? Should I just implement it without >>>>> generics? >>>>> Is there a webpage where we are listing api methods/fields which >>>>> involve >>>>> generics to later on update the code? >>>>> >>>>> >>>>> >>>> -- >>>> Paulex Yang >>>> China Software Development Lab >>>> IBM >>>> >>>> >>>> >>>> >>> >>> >> >> > -- Richard Liang China Software Development Lab, IBM