Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 84780 invoked from network); 23 Dec 2010 16:13:39 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Dec 2010 16:13:39 -0000 Received: (qmail 8669 invoked by uid 500); 23 Dec 2010 16:13:39 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 8238 invoked by uid 500); 23 Dec 2010 16:13:36 -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 8229 invoked by uid 99); 23 Dec 2010 16:13:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Dec 2010 16:13:35 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of firepure@gmail.com designates 209.85.213.49 as permitted sender) Received: from [209.85.213.49] (HELO mail-yw0-f49.google.com) (209.85.213.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Dec 2010 16:13:28 +0000 Received: by ywf7 with SMTP id 7so3025713ywf.36 for ; Thu, 23 Dec 2010 08:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=RTS/Gs/wwjNDJPA+QAzhEZsLav9cUjFhuVQEOHEamzI=; b=eznukBWkj1bXXX1d0M8/Wj+6iDtWGYBqo2iOfGIJG75GgSyQB0bro7NBDpEQUBQ/Ih xRrYvUqcZVu9Di1OdOHzvIcTgoCZcP3E199ThPOAY4q8NI5MgGrXkG2Ljb/zU7cmEFwL TpTjgJQ8tG/T838fv1SjkdOGBQtKiNQOdLk6Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=npxV2/4QroYWRDZ+DLTJSa7mI05677wllZEAj8fzfgbP7UmqPN93+TcszrnptkuqgE YD+VwM2zlfv0R6cCaRMzUxjiSm628ar8UIIygnupnwxQsM66IAWHAO+YYuCOxRNCJbQY IZ13pp+T4f2wp+lcAe1+6Ys50u/ZGV66aACdk= MIME-Version: 1.0 Received: by 10.236.105.180 with SMTP id k40mr586673yhg.93.1293120786747; Thu, 23 Dec 2010 08:13:06 -0800 (PST) Received: by 10.236.105.135 with HTTP; Thu, 23 Dec 2010 08:13:06 -0800 (PST) In-Reply-To: <36800.36910.qm@web55901.mail.re3.yahoo.com> References: <97274.78169.qm@web55903.mail.re3.yahoo.com> <293245.47077.qm@web55904.mail.re3.yahoo.com> <36800.36910.qm@web55901.mail.re3.yahoo.com> Date: Fri, 24 Dec 2010 00:13:06 +0800 Message-ID: Subject: Re: strong type cast needed in java. (overriding enhancement.) From: "Jimmy,Jing Lv" To: dev@harmony.apache.org Content-Type: multipart/alternative; boundary=00235444786325549104981625ac X-Virus-Checked: Checked by ClamAV on apache.org --00235444786325549104981625ac Content-Type: text/plain; charset=ISO-8859-1 Hi Hari, I see it may be possible to avoid the checking and implement the strong type casting - however I am still wondering why shall we overcome the difficulty, build a complex checking in compling to make it happen? Java is not c/c++ and has its own style. So again what is the benefit we can see if we have this feature? 2010/12/23 hari ks > c++: > base *b=new base; > sub *s=new sub; > s ->base::foo(); // private instance variable of base has 0 or unknown > value while executing foo() method of base class.. > > can't this be extended so as pass base class variable along with method > call? > may be something like > s -> base{i=20,j=11}::foo();// here i and j were private variables of > base.. > > this concept could be implemented in java. > > thanks & rgds, > Hari > > > > > ________________________________ > From: hari ks > To: dev@harmony.apache.org > Sent: Thu, December 23, 2010 6:06:46 PM > Subject: Re: strong type cast needed in java. (overriding enhancement.) > > hi , > > c++ allows more combinations between instructions(functions) and > data(variables) > > than java. > eg in c++: > base* b; > sub* s; // sub extends base and both have method foo().. > b -> foo(); // will call base foo() > s -> foo(); // will call sub foo() > s ->base::foo(); // will call base foo() > > java didn't add this mostly -because functions in super class might access > 'private members' of super class which there is no way populating in > subclass > object and throw Null Exception.. > Yet again - if these specific functions in superclass that could be > accessed > from subclass were compile time checked as not to access any private > variable of > > super class, this feature may add meaning. > > There could be more better design than just preventing subclass not to > access > super class methods.. > > thanks & rgds, > Hari > > > > ________________________________ > From: "Jimmy,Jing Lv" > To: dev@harmony.apache.org > Sent: Thu, December 23, 2010 3:34:51 PM > Subject: Re: strong type cast needed in java. (overriding enhancement.) > > Hi Hari, > > I see there is no such mechanism for Java now. I suppose it may be due > to java single inheritance and dynamic bonding. > Technically strong type casting is possible with bytecode instruction > or something, however I'd rather design it clear to avoid such invoking - > say, if you want A.foo(), create A a = new A(), or avoid overriding foo() > in > B. It sounds a syntax problem to invoke a parent method in a child class > instance while the method is already overrode. It may have some problem > with strong type casting. For an example, if you have a public basic type > A, > which has an implemented method foo(), and then create some internal > implementation B, C, which C extends B and both of them override foo(). > With > a factory of A you can get an object "a" which is really C instances, then > it will be hard to tell what can be invoked for a.super.foo()? > > Sorry I don't catch you that what is the benefit do you think for > strong type casting on Java? > > 2010/12/23 hari ks > > > I have put up a post here : > > > > > http://programparadigm.blogspot.com/2010/12/method-overriding-enhancements-strong.html > > > >l > > > > > > Suppose class B extends A. > > A a = new B(); > > ((A)a).foo(); // still calls class B's foo() method. > > > > Can something like "a.super.foo();" method invocation be made possible. > Or > > ((A > > strong)a).foo(); should call A's foo() method with B's instance data. > > > > similar thing for C++. > > > > Is there a way to already do this? > > > > thanks & regards, > > Hari > > > > > > > > > > > > > -- > > Best Regards! > > Jimmy, Jing Lv > > > > -- Best Regards! Jimmy, Jing Lv --00235444786325549104981625ac--