From dev-return-35654-apmail-harmony-dev-archive=harmony.apache.org@harmony.apache.org Tue Dec 16 09:53:45 2008 Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 49963 invoked from network); 16 Dec 2008 09:53:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Dec 2008 09:53:45 -0000 Received: (qmail 28058 invoked by uid 500); 16 Dec 2008 09:53:56 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 28032 invoked by uid 500); 16 Dec 2008 09:53:56 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 28021 invoked by uid 99); 16 Dec 2008 09:53:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 01:53:55 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of greensight@gmail.com designates 209.85.219.20 as permitted sender) Received: from [209.85.219.20] (HELO mail-ew0-f20.google.com) (209.85.219.20) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 09:53:40 +0000 Received: by ewy13 with SMTP id 13so3442584ewy.12 for ; Tue, 16 Dec 2008 01:53:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=uDIwq/v+eXOP3eVQbg+PHah6Ipvz+lRGTjLYOxygLQQ=; b=Pq0tqvU77rvGaAQVsz7TunNs4kUgX/NqvzIVZLAGgbBJzcdnjpWHojXWSAF9wKi6wg Cs/XwxtE49kmNwZjHmuCwOTwNRY4OkFexFeFGZiTRWRsZ4Dk+h+9Opsy1J6Rka+LOC9L B13kNjSOIUExInjfAiuGJ2wwY+q4UlqkdtnDQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=vIHs4ZIoBLIcEJ6O+Ownt2SYQtDxM0N2qdHdFRwooUGjNXvJrB3mFVgMxaJHGlgEUY mqadHk2JvHifAT9I5pCEBIND1hbB7rpE+Bul7/mgERAckCKKG84U+WTtQ0KM+aLCzs+c p86rvHIlAJgZMmVOlAa3WUGduhSc1QjULE7nI= Received: by 10.210.71.11 with SMTP id t11mr9010168eba.26.1229421200431; Tue, 16 Dec 2008 01:53:20 -0800 (PST) Received: by 10.210.116.16 with HTTP; Tue, 16 Dec 2008 01:53:20 -0800 (PST) Message-ID: <5e7fd1eb0812160153h1ce7df68k1673eacf2dd49593@mail.gmail.com> Date: Tue, 16 Dec 2008 17:53:20 +0800 From: "Jack Cai" To: dev@harmony.apache.org Subject: Re: [classlib]Make harmony's modularity better In-Reply-To: <4946C2B9.1040702@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_45716_4374629.1229421200434" References: <211709bc0812150226u2e49fa42u7acb999391d49fd4@mail.gmail.com> <49464A9D.3070904@gmail.com> <3b3f27c60812150723n25b0af8t3ac9d82f5c623e52@mail.gmail.com> <4946C2B9.1040702@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_45716_4374629.1229421200434 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Well, we can catch a Throwable instead of a checked exception. This will also catch Error. We can re-throw non-class-not-found exceptions/errors. -Jack 2008/12/16 Tim Ellison > Nathan Beyer wrote: > > What are the guarantees of dynamic class loading? I've never been > > quite sure what you can and can't get away with. > > Depends what you mean by 'guarantee'? > > The class is loaded at the first reference to it, or as the VM spec [1] > says: > "Creation of a class or interface C [...] is triggered by another class > or interface D, which references C through its runtime constant pool. > Class or interface creation may also be triggered by D invoking methods > in certain Java class libraries (=A73.12) such as reflection." > > [1] > > http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.= html#72007 > > > Wouldn't the bit below need to catch ClassNotFoundError? An > > The 'bit below' is protected by the isApplet test, so if we figured out > it was not an applet we won't reference the Applet class again. > > However, my code below won't compile, since ClassNotFoundException is a > checked exception, so we'd need to do a Class.forName() in the exception > handler rather than instanceof. > > Regards, > Tim > > > On Mon, Dec 15, 2008 at 6:16 AM, Tim Ellison > wrote: > >> Alexei Fedotov wrote: > >>> I like when a compiler does a hard job of type and method checking. > >>> Why should we use reflection and hide applet dependency, hence > >>> prohibiting the compiler to check things for us? > >> Right. > >> > >> Why not make use of Java's dynamic loading ... something like this > >> (untested): > >> > >> Index: src/main/java/java/beans/Beans.java > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- src/main/java/java/beans/Beans.java (revision 725055) > >> +++ src/main/java/java/beans/Beans.java (working copy) > >> @@ -198,7 +198,13 @@ > >> > >> if (result !=3D null) { > >> // Applet specific initialization > >> - if (result instanceof Applet) { > >> + boolean isApplet =3D false; > >> + try { > >> + isApplet =3D result instanceof Applet; > >> + } catch (ClassNotFoundException e) { > >> + // Ignored - leave isApplet as false. > >> + } > >> + if (isApplet) { > >> appletLoaded((Applet) result, loader, > beanName, context, > >> initializer, > deserialized); > >> } > >> > >> > >> Regards, > >> Tim > >> > >>> If this was C, I'd made a common header describing initialization for > >>> two modules. > >>> > >>> Thanks. > >>> > >>> On Mon, Dec 15, 2008 at 2:35 PM, Sian January > >>> wrote: > >>>> Hi Tony, > >>>> > >>>> I think it would be very good if we could minimise unnecessary > >>>> dependencies between Harmony modules. I would definitely like to ge= t > >>>> involved with this. > >>>> > >>>> For the specific example, don't forget that Applet is not final so > >>>> could be subclassed, in which case class.getName() would return > >>>> something else. However you should still be able to do it with > >>>> refection, (e.g. something like > >>>> Class.forName("java.applet.Applet").cast(result)) > >>>> > >>>> Thanks, > >>>> > >>>> Sian > >>>> > >>>> > >>>> 2008/12/15 Tony Wu : > >>>>> Hi, all > >>>>> > >>>>> Just came across a problem. when I was running beans without the > >>>>> applet.jar in classpath, the jre throws "NoClassFoundExcetipn: > Applet" > >>>>> and exit even the bean class I was operating was not an applet. I d= id > >>>>> a quick look into the Beans.java, there are some code for applet > >>>>> specific initialization, > >>>>> > >>>>> if (result !=3D null) { > >>>>> // Applet specific initialization > >>>>> if (result instanceof Applet) { > >>>>> appletLoaded((Applet) result, loader= , > beanName, context, > >>>>> initializer, > deserialized); > >>>>> } > >>>>> if (null !=3D context) { > >>>>> context.add(result); > >>>>> } > >>>>> } > >>>>> > >>>>> I think at least we can make some change to the the line "result > >>>>> instanceof Applet", such as getClass.getName.equals to avoid this > >>>>> unexpected exit. > >>>>> Furthermore, I just simply deleted the dependencies to some non-lun= i > >>>>> classes in the manifest files. By tracing these compiler errors in > >>>>> eclipse, I found there are some similiar cases in beans and other > >>>>> modules as well, I'm going to tidy up these code and make our > >>>>> modularity better. > >>>>> > >>>>> It is welcome if anyone has interest on this task and would like to > help. > >>>>> -- > >>>>> Tony Wu > >>>>> China Software Development Lab, IBM > >>>>> > >>>> > >>>> -- > >>>> Unless stated otherwise above: > >>>> IBM United Kingdom Limited - Registered in England and Wales with > number 741598. > >>>> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire P= O6 > 3AU > >>>> > >>> > >>> > > > ------=_Part_45716_4374629.1229421200434--