ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: ant-1.7.0_beta2: ant.jar depends on ant-nodeps.jar due to WeakishReference
Date Thu, 05 Oct 2006 09:15:02 GMT
Kevin Jackson wrote:
> Inline patch as gmail seems to not like .patch attachments today:

This is almost like what I have done, except I kept WeakishReference 
abstract, and had WeakReference12 extend HardReference. That way the 
base class remains abstract.

-steve

> 
> Index: org/apache/tools/ant/util/WeakishReference.java
> 
> ===================================================================
> 
> --- org/apache/tools/ant/util/WeakishReference.java    (revision 453080)
> 
> +++ org/apache/tools/ant/util/WeakishReference.java    (working copy)
> 
> @@ -18,7 +18,7 @@
> 
> 
> package org.apache.tools.ant.util;
> 
> -import org.apache.tools.ant.util.optional.WeakishReference12;
> +import java.lang.ref.WeakReference;
> 
> /**
>  * This is a weak reference on java1.2 and up, that is all
> @@ -27,8 +27,10 @@
> 
>  * @deprecated since 1.7.
>  *             Just use {@link java.lang.ref.WeakReference} directly.
>  */
> -public abstract class WeakishReference  {
> +public class WeakishReference  {
> 
> +    private WeakReference weakref;
> +
>     /**
>      * create the appropriate type of reference for the java version
>      * @param object the object that the reference will refer to.
> @@ -35,17 +37,23 @@
> 
>      * @return reference to the Object.
>      */
>     public static WeakishReference createReference(Object object) {
> -            return new WeakishReference12(object);
> +        return new WeakishReference(object);
>     }
> 
> +    public WeakishReference(Object reference) {
> +        this.weakref = new WeakReference(reference);
> +    }
> +
> +    public WeakishReference() {/* default */}
> +
>     /**
> -     * Returns this reference object's referent.  If this reference 
> object has
> -     * been cleared, then this method returns <code>null</code>.
> +     * Returns this reference object's referent.
>      *
> -     * @return The object to which this reference refers, or
> -     *         <code>null</code> if this reference object has been 
> cleared.
> +     * @return referent.
>      */
> -    public abstract Object get();
> +    public Object get() {
> +        return weakref.get();
> +    }
> 
>     /**
>      * A hard reference for Java 1.1.
> @@ -53,7 +61,6 @@
> 
>      *             Hopefully nobody is using this.
>      */
>     public static class HardReference extends WeakishReference {
> -        private Object object;
> 
>         /**
>          * constructor.
> @@ -60,7 +67,7 @@
> 
>          * @param object the object that the reference will refer to.
>          */
>         public HardReference(Object object) {
> -            this.object = object;
> +            super(object);
>         }
> 
>         /**
> @@ -68,8 +75,7 @@
> 
>          * @return the object to which this reference refers.
>          */
>         public Object get() {
> -            return object;
> +            return super.get();
>         }
>     }
> -
> -}
> +}
> 
> \ No newline at end of file
> 
> Index: org/apache/tools/ant/util/optional/WeakishReference12.java
> 
> ===================================================================
> 
> --- org/apache/tools/ant/util/optional/WeakishReference12.java    
> (revision 453080)
> 
> +++ org/apache/tools/ant/util/optional/WeakishReference12.java    
> (working copy)
> 
> @@ -20,8 +20,6 @@
> 
> 
> import org.apache.tools.ant.util.WeakishReference;
> 
> -import java.lang.ref.WeakReference;
> -
> /**
>  * This is a reference that really is is Weak, as it uses the
>  * appropriate java.lang.ref class.
> @@ -30,25 +28,4 @@
> 
>  */
> public class WeakishReference12 extends WeakishReference  {
> 
> -    private WeakReference weakref;
> -
> -    /**
> -     * create a new soft reference, which is bound to a
> -     * Weak reference inside
> -     * @param reference
> -     * @see java.lang.ref.WeakReference
> -     */
> -    public WeakishReference12(Object reference) {
> -        this.weakref = new WeakReference(reference);
> -    }
> -
> -    /**
> -     * Returns this reference object's referent.
> -     *
> -     * @return referent.
> -     */
> -    public Object get() {
> -        return weakref.get();
> -    }
> -
> -}
> +}
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 


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


Mime
View raw message