[slf4j-user] Re: Re: Varargs for Logger methods
Kostis Anagnostopoulos
ankostis at gmail.com
Thu Feb 16 15:27:16 CET 2006
Resending my previous msg for correcting a minor typo in code fragment,
along with a new notice.
On 2/16/06, Ceki Gülcü <listid at qos.ch> wrote:
> At 01:25 PM 2/16/2006, Kostis Anagnostopoulos wrote:
> >Thank you for your quick response,
>
> You are welcome.
>
> >At Thu Feb 16 10:58:57 CET 2006, Ceki Gülcü wrote:
> > >....
> > >Several experiments show that modifying o.s.Logger for varargs use would be
> > >fairly straightforward. Existing clients would need to recompile their code
> > >against the "upgraded" SLF4J API. No other changes would be necessary.
> >
> >Not even this! Existing clients (those that are not using varags) would
> >require no recompilation, unless the API changes in a non-compatible way
> >(ie, some of its methods removed).
> >So, lets leave the old ones (those with 2 object params) and
> >just add the varag-ified ones.
>
> I don't think adding varag-ified *overloaded* methods is possible. If it
> were possible, then what you suggest makes sense.
>
> Take a simplified version of Logger:
>
> public interface Logger {
>
> void log(String msg);
> void log(String msg, Object[] argArray);
> void log(String msg, Object ... args);
> }
>
> If you try to compile it, you will get:
>
> # javac Logger.java
> Logger.java:7: log(java.lang.String,java.lang.Object[]) is already defined
> in Logger
> void log(String msg, Object ... args);
> ^
> 1 error
>
> >Only newly-written clients that take advantage of the new varg-ified API
> >require compile.
> >
> >
> > >However, it would *not* be possible to mix classes compiled against SLF4J
> > >versions targeting 1.4 and those targeting 1.5.
> >
> >Why is that?
> >Code compiled against 1.4 and non-varag SLF4J would also run
> >in VM 1.5.
> >Also if the varag-ified SLF4J API is modified compatible (see above),
> >then it would run OK.
> >
> >Am i missing something here?
>
> Have you overlooked the fact that varargs methods cannot be added on top of
> existing methods taking Object[] as their last argument.
>
> Do you have any ideas on how to overcome this impossibility?
>
But i thought it was obvious that the old method:
void log(String msg, Object[] argArray);
will be replaced the new method:
void log(String msg, Object ... args);
Since java specs guarantee that older client code (the one that using Object[])
will always work with varags, the method:
void log(String msg, Object[] argArray);
is no longer needed!
I'm emphasizing, at this point, that i suggest to have 2 completely
different jar
families, one for java pre-1.5 and one for java-1.5, since the java-1.5 jars
would not load with pre-1.5 VMs!.
ankostis
> --
> Ceki Gülcü
>
> _______________________________________________
> user mailing list
> user at slf4j.org
> http://slf4j.org/mailman/listinfo/user
>
More information about the slf4j-user
mailing list