You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Anders Kristensen <ak...@dynamicsoft.com> on 2001/06/18 18:39:50 UTC

Re: [Update] source that handles classloading properly on Java 1.X versus Java 2.X

Alternatively, inspect the "java.specification.version" system property.
For JDK 1.3 it's "1.3".

Anders


Michael McCauley wrote:
> 
> Chris,
> 
> In the source code for VersionHelper,  the getInstance method is as follows.
> 
>         public static VersionHelper getInstance()
>         {
>      if (helper == null)
>      {
>             try
>             {
>            // Try and load a class from JDK 1.2 or higher
>                 Class.forName("java.util.List");
>                 return
> (VersionHelper)Class.forName("org.apache.log4j.helpers.VersionHelper11").new
> Instance();
>             }
>             catch (ClassNotFoundException oops)
>             {
>                 return new VersionHelper11();
>             }
>      return helper;
>    }
> 
> Are you sure this is correct? Should it not be the following?
> 
>   public static VersionHelper getInstance()
>   {
>     if (helper == null)
>     {
>         try
>       {
>           // Try and load a class from JDK 1.1 or higher // **** change to
> the comment 1.2 -> 1.1
>           Class.forName("java.util.List");
>           helper =
> (VersionHelper)Class.forName("org.apache.log4j.VersionHelper11").newInstance
> ();
>       }
>         catch (Exception oops)
>       {
>           helper = new VersionHelper20();                // **** this is the
> important change 11 -> 20
>         }
>     }
>     return helper;
>   }
> 
> Regards,
> Mick.
> 
> **********************************************************************
> The information contained in this message is confidential and
> is intended for the addressee(s) only.  If you have received
> this message in error or there are any problems please notify
> the originator immediately.  The unauthorised use, disclosure,
> copying or alteration of this message is strictly forbidden. This
> message and any attachments have been scanned for viruses.
> Orbiscom Ltd. will not be liable for direct, special, indirect or
> consequential damages arising from alteration of the contents
> of this message by a third party or as a result of any virus being
> passed on.
> 
> www.Orbiscom.com
> **************************************
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Re: [Update] source that handles classloading properly on Java 1.X versus Java 2.X

Posted by Christopher Taylor <cs...@pacbell.net>.
That's a good idea... the code would be similar, except we'd catch
SecurityException instead of ClassNotFoundException.

-Chris
----- Original Message -----
From: "Anders Kristensen" <ak...@dynamicsoft.com>
To: "LOG4J Developers Mailing List" <lo...@jakarta.apache.org>
Sent: Monday, June 18, 2001 9:39 AM
Subject: Re: [Update] source that handles classloading properly on Java 1.X
versus Java 2.X


> Alternatively, inspect the "java.specification.version" system property.
> For JDK 1.3 it's "1.3".
>
> Anders
>
>
> Michael McCauley wrote:
> >
> > Chris,
> >
> > In the source code for VersionHelper,  the getInstance method is as
follows.
> >
> >         public static VersionHelper getInstance()
> >         {
> >      if (helper == null)
> >      {
> >             try
> >             {
> >            // Try and load a class from JDK 1.2 or higher
> >                 Class.forName("java.util.List");
> >                 return
> >
(VersionHelper)Class.forName("org.apache.log4j.helpers.VersionHelper11").new
> > Instance();
> >             }
> >             catch (ClassNotFoundException oops)
> >             {
> >                 return new VersionHelper11();
> >             }
> >      return helper;
> >    }
> >
> > Are you sure this is correct? Should it not be the following?
> >
> >   public static VersionHelper getInstance()
> >   {
> >     if (helper == null)
> >     {
> >         try
> >       {
> >           // Try and load a class from JDK 1.1 or higher // **** change
to
> > the comment 1.2 -> 1.1
> >           Class.forName("java.util.List");
> >           helper =
> >
(VersionHelper)Class.forName("org.apache.log4j.VersionHelper11").newInstance
> > ();
> >       }
> >         catch (Exception oops)
> >       {
> >           helper = new VersionHelper20();                // **** this is
the
> > important change 11 -> 20
> >         }
> >     }
> >     return helper;
> >   }
> >
> > Regards,
> > Mick.
> >
> > **********************************************************************
> > The information contained in this message is confidential and
> > is intended for the addressee(s) only.  If you have received
> > this message in error or there are any problems please notify
> > the originator immediately.  The unauthorised use, disclosure,
> > copying or alteration of this message is strictly forbidden. This
> > message and any attachments have been scanned for viruses.
> > Orbiscom Ltd. will not be liable for direct, special, indirect or
> > consequential damages arising from alteration of the contents
> > of this message by a third party or as a result of any virus being
> > passed on.
> >
> > www.Orbiscom.com
> > **************************************
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Re: [Update] source that handles classloading properly on Java 1.X versus Java 2.X

Posted by Ceki Gülcü <cg...@qos.ch>.

Indeed, checking for "java.specification.version" system property looks cleaner to me. Ceki

At 12:39 18.06.2001 -0400, you wrote:
>Alternatively, inspect the "java.specification.version" system property.
>For JDK 1.3 it's "1.3".
>
>Anders
>
>
>Michael McCauley wrote:
>> 
>> Chris,
>> 
>> In the source code for VersionHelper,  the getInstance method is as follows.
>> 
>>         public static VersionHelper getInstance()
>>         {
>>      if (helper == null)
>>      {
>>             try
>>             {
>>            // Try and load a class from JDK 1.2 or higher
>>                 Class.forName("java.util.List");
>>                 return
>> (VersionHelper)Class.forName("org.apache.log4j.helpers.VersionHelper11").new
>> Instance();
>>             }
>>             catch (ClassNotFoundException oops)
>>             {
>>                 return new VersionHelper11();
>>             }
>>      return helper;
>>    }
>> 
>> Are you sure this is correct? Should it not be the following?
>> 
>>   public static VersionHelper getInstance()
>>   {
>>     if (helper == null)
>>     {
>>         try
>>       {
>>           // Try and load a class from JDK 1.1 or higher // **** change to
>> the comment 1.2 -> 1.1
>>           Class.forName("java.util.List");
>>           helper =
>> (VersionHelper)Class.forName("org.apache.log4j.VersionHelper11").newInstance
>> ();
>>       }
>>         catch (Exception oops)
>>       {
>>           helper = new VersionHelper20();                // **** this is the
>> important change 11 -> 20
>>         }
>>     }
>>     return helper;
>>   }
>> 
>> Regards,
>> Mick.
>> 
>> **********************************************************************
>> The information contained in this message is confidential and
>> is intended for the addressee(s) only.  If you have received
>> this message in error or there are any problems please notify
>> the originator immediately.  The unauthorised use, disclosure,
>> copying or alteration of this message is strictly forbidden. This
>> message and any attachments have been scanned for viruses.
>> Orbiscom Ltd. will not be liable for direct, special, indirect or
>> consequential damages arising from alteration of the contents
>> of this message by a third party or as a result of any virus being
>> passed on.
>> 
>> www.Orbiscom.com
>> **************************************
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

--
Ceki Gülcü


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org