Browse Source

#32463: deprecate WeakishReference since we can assume JDK 1.2 APIs now.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278067 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 20 years ago
parent
commit
df49dea906
3 changed files with 3 additions and 48 deletions
  1. +2
    -1
      src/main/org/apache/tools/ant/util/WeakishReference.java
  2. +1
    -1
      src/main/org/apache/tools/ant/util/optional/WeakishReference12.java
  3. +0
    -46
      src/testcases/org/apache/tools/ant/util/ReferencesTest.java

+ 2
- 1
src/main/org/apache/tools/ant/util/WeakishReference.java View File

@@ -23,6 +23,7 @@ import org.apache.tools.ant.util.optional.WeakishReference12;
* This is a weak reference on java1.2 and up, that is all
* platforms Ant1.6 supports.
* @since ant1.6
* @deprecated Just use {@link java.lang.ref.WeakReference} directly.
*/
public abstract class WeakishReference {

@@ -46,7 +47,7 @@ public abstract class WeakishReference {

/**
* A hard reference for Java 1.1.
* Hopefully nobody is using this.
* @deprecated Hopefully nobody is using this.
*/
public static class HardReference extends WeakishReference {
private Object object;


+ 1
- 1
src/main/org/apache/tools/ant/util/optional/WeakishReference12.java View File

@@ -24,7 +24,7 @@ import java.lang.ref.WeakReference;
/**
* This is a reference that really is is Weak, as it uses the
* appropriate java.lang.ref class.
*
* @deprecated Just use {@link WeakReference} directly.
*/
public class WeakishReference12 extends WeakishReference {



+ 0
- 46
src/testcases/org/apache/tools/ant/util/ReferencesTest.java View File

@@ -1,46 +0,0 @@
/*
* Copyright 2002,2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.util;

import junit.framework.TestCase;


/**
* this test just makes sure that we really do create weak references
* on java1.2+, and is written to not import the WeakishReference12 class
* because then we'd have to make the class conditional on java1.2+.
*/
public class ReferencesTest extends TestCase{

public ReferencesTest(String s) {
super(s);
}

/**
* look at the type of a reference we have created
*/
public static void testReferencesAreSoft() {
boolean isJava11=JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1);
WeakishReference reference = WeakishReference.createReference(new Object());
if ((reference.getClass().getName().indexOf("HardReference") > 0 )
&& !isJava11) {
fail("We should be creating soft references in this version of Java");
}
}

}

Loading…
Cancel
Save