Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 40812 invoked from network); 27 Nov 2009 02:43:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Nov 2009 02:43:27 -0000 Received: (qmail 7484 invoked by uid 500); 27 Nov 2009 02:43:27 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 7228 invoked by uid 500); 27 Nov 2009 02:43:26 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 7218 invoked by uid 99); 27 Nov 2009 02:43:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Nov 2009 02:43:26 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paulus.benedictus@gmail.com designates 209.85.223.185 as permitted sender) Received: from [209.85.223.185] (HELO mail-iw0-f185.google.com) (209.85.223.185) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Nov 2009 02:43:17 +0000 Received: by iwn15 with SMTP id 15so687033iwn.10 for ; Thu, 26 Nov 2009 18:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=c0IrAuwvlxSB3OziRXcFyQXOk/FfzRPUzgGRYtrQSZs=; b=X4mE3Vlarsu4Zejv2LTh0p7rrbkjVz4HRskgouFoE6xy196HdO8LkD2xtW+XzRGua9 wlt8iT3K/Y5fRbGsx5mLZpnxpB5fCiSfxfuAoJX9S0jzRqlbipXMQ1XMmo0SccmMrgjZ pz0JT8J1feVMem/3H8c6lDLFBUiVSn+bgXxEs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=bLpO3RLVU/QqVmJ5Mi4OxYossSXrL2tG3nUnm75dWjgXTAP6lEGwh9N0CCiCvEkW1t Qn/itmllZlHlIyeaBIiHyh+AtwBNBoToV0Tdz2du9r9XwkFL1L970oEV1RIjVC85++0T e/Eu54qsCSCiJjw7GdYpI35nlJ40DLB6gstkA= MIME-Version: 1.0 Sender: paulus.benedictus@gmail.com Received: by 10.231.29.149 with SMTP id q21mr1100129ibc.35.1259289776855; Thu, 26 Nov 2009 18:42:56 -0800 (PST) In-Reply-To: References: Date: Thu, 26 Nov 2009 20:42:56 -0600 X-Google-Sender-Auth: 0c5f04f96c0ac6c1 Message-ID: Subject: Re: [lang 3] static or dynamic type checks? From: Paul Benedict To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org James, The compiler instantiates the Object[] every time because that's how the ellipsis notation is translated. Paul On Thu, Nov 26, 2009 at 7:38 PM, James Carman wrote: > Yes, but if the check passes, there's no need to create the Object[] > for single-argument method invocations. > > On Thu, Nov 26, 2009 at 10:59 AM, Paul Benedict wr= ote: >> The purpose of var-args, at least from my vantage, is to produce >> detail messages that are used by java.lang.String.format. >> >> Paul >> >> On Thu, Nov 26, 2009 at 7:11 AM, James Carman >> wrote: >>> I just wrote a class that included... >>> >>> =A0 =A0public static T someMethod(T val) >>> =A0 =A0{ >>> =A0 =A0 =A0 =A0System.out.println("Single value method!"); >>> =A0 =A0 =A0 =A0return val; >>> =A0 =A0} >>> >>> =A0 =A0public static T[] someMethod(T... values) >>> =A0 =A0{ >>> =A0 =A0 =A0 =A0System.out.println("Multi-value method."); >>> =A0 =A0 =A0 =A0return values; >>> =A0 =A0} >>> >>> =A0 =A0public static void main(String[] args) >>> =A0 =A0{ >>> =A0 =A0 =A0 =A0someMethod("Hello"); >>> =A0 =A0 =A0 =A0someMethod("Hello", "World"); >>> =A0 =A0} >>> >>> When I ran it, it printed: >>> >>> Single value method! >>> Multi-value method. >>> >>> So, what's the big deal? =A0Create a single-value method and create a >>> multi-value method. =A0I must be missing something in this discussion. >>> >>> On Thu, Nov 26, 2009 at 12:16 AM, Paul Benedict = wrote: >>>> If we want to implement LANG-508 (Validate: add message parameter >>>> construction via elllipsis notation to speed up processing), I am >>>> really concerned with the many overloaded versions of #validIndex() >>>> and #notEmpty() that solely differ by static argument type: >>>> Collection, Object, Object[], CharSequence, etc. >>>> >>>> Because var-args instantiate a new Object[], it won't be possible to >>>> easily create one-argument optimized overloaded versions to prevent >>>> the creation. Such as: >>>> public static T[] notEmpty(Object array, String message, Object va= r1); >>>> public static T[] notEmpty(Object array, String message, Object >>>> var1, Object var2); >>>> public static T[] notEmpty(Object array, String message, Object >>>> var1, Object var2, Object var3); >>>> public static T[] notEmpty(Object array, String message, Object >>>> var1, Object var2, Object var3, Object... vars); >>>> >>>> I am following the good advice on Joshua Bloch on this one. It's item >>>> #42 in his Effective Java book. >>>> >>>> I want to eliminate the overloaded versions by type and check those >>>> types using instanceof instead. Thoughts? >>>> >>>> Paul >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>>> For additional commands, e-mail: dev-help@commons.apache.org >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org