Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8196586: Remove use of deprecated finalize methods from javafx property objects #113

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -163,17 +163,6 @@ private static <T extends Number> BidirectionalBinding bindNumber(Property<T> pr
return binding;
}

public static <T extends Number> void unbindNumber(Property<T> property1, Property<Number> property2) {
checkParameters(property1, property2);
final BidirectionalBinding binding = new UntypedGenericBidirectionalBinding(property1, property2);
if (property1 instanceof ObservableValue) {
((ObservableValue) property1).removeListener(binding);
}
if (property2 instanceof Observable) {
((ObservableValue) property2).removeListener(binding);
}
}

private final int cachedHashCode;

private BidirectionalBinding(Object property1, Object property2) {
Expand Down
Expand Up @@ -31,10 +31,6 @@
import javafx.beans.value.WritableBooleanValue;
import com.sun.javafx.binding.Logging;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* This class provides a full implementation of a {@link Property} wrapping a
* {@code boolean} value.
Expand Down Expand Up @@ -141,7 +137,6 @@ public static BooleanProperty booleanProperty(final Property<Boolean> property)
throw new NullPointerException("Property cannot be null");
}
return property instanceof BooleanProperty ? (BooleanProperty)property : new BooleanPropertyBase() {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bind(this, property);
}
Expand All @@ -155,18 +150,6 @@ public Object getBean() {
public String getName() {
return property.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbind(property, this);
return null;
}, acc);
} finally {
super.finalize();
}
}
};
}

Expand All @@ -182,7 +165,6 @@ protected void finalize() throws Throwable {
@Override
public ObjectProperty<Boolean> asObject() {
return new ObjectPropertyBase<Boolean> () {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bind(this, BooleanProperty.this);
}
Expand All @@ -196,19 +178,6 @@ public Object getBean() {
public String getName() {
return BooleanProperty.this.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbind(this, BooleanProperty.this);
return null;
}, acc);
} finally {
super.finalize();
}
}

};
}
}
Expand Up @@ -37,10 +37,6 @@
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableDoubleValue;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* This class defines a {@link Property} wrapping a {@code double} value.
* <p>
Expand Down Expand Up @@ -156,7 +152,6 @@ public static DoubleProperty doubleProperty(final Property<Double> property) {
throw new NullPointerException("Property cannot be null");
}
return new DoublePropertyBase() {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, property);
}
Expand All @@ -170,18 +165,6 @@ public Object getBean() {
public String getName() {
return property.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(property, this);
return null;
}, acc);
} finally {
super.finalize();
}
}
};
}

Expand All @@ -207,7 +190,6 @@ protected void finalize() throws Throwable {
@Override
public ObjectProperty<Double> asObject() {
return new ObjectPropertyBase<Double> () {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, DoubleProperty.this);
}
Expand All @@ -221,19 +203,6 @@ public Object getBean() {
public String getName() {
return DoubleProperty.this.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(this, DoubleProperty.this);
return null;
}, acc);
} finally {
super.finalize();
}
}

};
}

Expand Down
Expand Up @@ -31,10 +31,6 @@
import javafx.beans.value.WritableFloatValue;
import com.sun.javafx.binding.Logging;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* This class defines a {@link Property} wrapping a {@code float} value.
* <p>
Expand Down Expand Up @@ -151,7 +147,6 @@ public static FloatProperty floatProperty(final Property<Float> property) {
throw new NullPointerException("Property cannot be null");
}
return new FloatPropertyBase() {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, property);
}
Expand All @@ -165,18 +160,6 @@ public Object getBean() {
public String getName() {
return property.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(property, this);
return null;
}, acc);
} finally {
super.finalize();
}
}
};
}

Expand All @@ -202,7 +185,6 @@ protected void finalize() throws Throwable {
@Override
public ObjectProperty<Float> asObject() {
return new ObjectPropertyBase<Float> () {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, FloatProperty.this);
}
Expand All @@ -216,19 +198,6 @@ public Object getBean() {
public String getName() {
return FloatProperty.this.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(this, FloatProperty.this);
return null;
}, acc);
} finally {
super.finalize();
}
}

};
}

Expand Down
Expand Up @@ -31,10 +31,6 @@
import javafx.beans.value.WritableIntegerValue;
import com.sun.javafx.binding.Logging;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* This class defines a {@link Property} wrapping an {@code int} value.
* <p>
Expand Down Expand Up @@ -151,7 +147,6 @@ public static IntegerProperty integerProperty(final Property<Integer> property)
throw new NullPointerException("Property cannot be null");
}
return new IntegerPropertyBase() {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, property);
}
Expand All @@ -165,18 +160,6 @@ public Object getBean() {
public String getName() {
return property.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(property, this);
return null;
}, acc);
} finally {
super.finalize();
}
}
};
}

Expand All @@ -202,7 +185,6 @@ protected void finalize() throws Throwable {
@Override
public ObjectProperty<Integer> asObject() {
return new ObjectPropertyBase<Integer> () {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, IntegerProperty.this);
}
Expand All @@ -216,19 +198,6 @@ public Object getBean() {
public String getName() {
return IntegerProperty.this.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(this, IntegerProperty.this);
return null;
}, acc);
} finally {
super.finalize();
}
}

};
}
}
Expand Up @@ -31,10 +31,6 @@
import javafx.beans.value.WritableLongValue;
import com.sun.javafx.binding.Logging;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* This class defines a {@link Property} wrapping a {@code long} value.
* <p>
Expand Down Expand Up @@ -149,7 +145,6 @@ public static LongProperty longProperty(final Property<Long> property) {
throw new NullPointerException("Property cannot be null");
}
return new LongPropertyBase() {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, property);
}
Expand All @@ -163,18 +158,6 @@ public Object getBean() {
public String getName() {
return property.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(property, this);
return null;
}, acc);
} finally {
super.finalize();
}
}
};
}

Expand All @@ -200,7 +183,6 @@ protected void finalize() throws Throwable {
@Override
public ObjectProperty<Long> asObject() {
return new ObjectPropertyBase<Long> () {
private final AccessControlContext acc = AccessController.getContext();
{
BidirectionalBinding.bindNumber(this, LongProperty.this);
}
Expand All @@ -214,19 +196,6 @@ public Object getBean() {
public String getName() {
return LongProperty.this.getName();
}

@Override
protected void finalize() throws Throwable {
try {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
BidirectionalBinding.unbindNumber(this, LongProperty.this);
return null;
}, acc);
} finally {
super.finalize();
}
}

};
}
}