All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.lang.ref.SoftReference Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.

There is a newer version: 0.6.8
Show newest version
package java.lang.ref;

public class SoftReference extends Reference {
	private long time;

	static private long getTime() {
		return System.currentTimeMillis();
	}

	public SoftReference(T referent) {
		super(referent);
		this.time = getTime();
	}

	public SoftReference(T referent, ReferenceQueue q) {
		super(referent, q);
		this.time = getTime();
	}

	public T get() {
		T o = super.get();
		long current = getTime();
		if (o != null && this.time != current) this.time = current;
		return o;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy