Skip to content

Commit 9cd6f79

Browse files
8196586: Remove use of deprecated finalize methods from javafx property objects
Reviewed-by: nlisker, arapte
1 parent ef2f9ce commit 9cd6f79

File tree

7 files changed

+215
-166
lines changed

7 files changed

+215
-166
lines changed

modules/javafx.base/src/main/java/com/sun/javafx/binding/BidirectionalBinding.java

-11
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,6 @@ private static <T extends Number> BidirectionalBinding bindNumber(Property<T> pr
163163
return binding;
164164
}
165165

166-
public static <T extends Number> void unbindNumber(Property<T> property1, Property<Number> property2) {
167-
checkParameters(property1, property2);
168-
final BidirectionalBinding binding = new UntypedGenericBidirectionalBinding(property1, property2);
169-
if (property1 instanceof ObservableValue) {
170-
((ObservableValue) property1).removeListener(binding);
171-
}
172-
if (property2 instanceof Observable) {
173-
((ObservableValue) property2).removeListener(binding);
174-
}
175-
}
176-
177166
private final int cachedHashCode;
178167

179168
private BidirectionalBinding(Object property1, Object property2) {

modules/javafx.base/src/main/java/javafx/beans/property/BooleanProperty.java

-31
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
import javafx.beans.value.WritableBooleanValue;
3232
import com.sun.javafx.binding.Logging;
3333

34-
import java.security.AccessControlContext;
35-
import java.security.AccessController;
36-
import java.security.PrivilegedAction;
37-
3834
/**
3935
* This class provides a full implementation of a {@link Property} wrapping a
4036
* {@code boolean} value.
@@ -141,7 +137,6 @@ public static BooleanProperty booleanProperty(final Property<Boolean> property)
141137
throw new NullPointerException("Property cannot be null");
142138
}
143139
return property instanceof BooleanProperty ? (BooleanProperty)property : new BooleanPropertyBase() {
144-
private final AccessControlContext acc = AccessController.getContext();
145140
{
146141
BidirectionalBinding.bind(this, property);
147142
}
@@ -155,18 +150,6 @@ public Object getBean() {
155150
public String getName() {
156151
return property.getName();
157152
}
158-
159-
@Override
160-
protected void finalize() throws Throwable {
161-
try {
162-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
163-
BidirectionalBinding.unbind(property, this);
164-
return null;
165-
}, acc);
166-
} finally {
167-
super.finalize();
168-
}
169-
}
170153
};
171154
}
172155

@@ -182,7 +165,6 @@ protected void finalize() throws Throwable {
182165
@Override
183166
public ObjectProperty<Boolean> asObject() {
184167
return new ObjectPropertyBase<Boolean> () {
185-
private final AccessControlContext acc = AccessController.getContext();
186168
{
187169
BidirectionalBinding.bind(this, BooleanProperty.this);
188170
}
@@ -196,19 +178,6 @@ public Object getBean() {
196178
public String getName() {
197179
return BooleanProperty.this.getName();
198180
}
199-
200-
@Override
201-
protected void finalize() throws Throwable {
202-
try {
203-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
204-
BidirectionalBinding.unbind(this, BooleanProperty.this);
205-
return null;
206-
}, acc);
207-
} finally {
208-
super.finalize();
209-
}
210-
}
211-
212181
};
213182
}
214183
}

modules/javafx.base/src/main/java/javafx/beans/property/DoubleProperty.java

-31
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737
import javafx.beans.value.ChangeListener;
3838
import javafx.beans.value.ObservableDoubleValue;
3939

40-
import java.security.AccessControlContext;
41-
import java.security.AccessController;
42-
import java.security.PrivilegedAction;
43-
4440
/**
4541
* This class defines a {@link Property} wrapping a {@code double} value.
4642
* <p>
@@ -156,7 +152,6 @@ public static DoubleProperty doubleProperty(final Property<Double> property) {
156152
throw new NullPointerException("Property cannot be null");
157153
}
158154
return new DoublePropertyBase() {
159-
private final AccessControlContext acc = AccessController.getContext();
160155
{
161156
BidirectionalBinding.bindNumber(this, property);
162157
}
@@ -170,18 +165,6 @@ public Object getBean() {
170165
public String getName() {
171166
return property.getName();
172167
}
173-
174-
@Override
175-
protected void finalize() throws Throwable {
176-
try {
177-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
178-
BidirectionalBinding.unbindNumber(property, this);
179-
return null;
180-
}, acc);
181-
} finally {
182-
super.finalize();
183-
}
184-
}
185168
};
186169
}
187170

@@ -207,7 +190,6 @@ protected void finalize() throws Throwable {
207190
@Override
208191
public ObjectProperty<Double> asObject() {
209192
return new ObjectPropertyBase<Double> () {
210-
private final AccessControlContext acc = AccessController.getContext();
211193
{
212194
BidirectionalBinding.bindNumber(this, DoubleProperty.this);
213195
}
@@ -221,19 +203,6 @@ public Object getBean() {
221203
public String getName() {
222204
return DoubleProperty.this.getName();
223205
}
224-
225-
@Override
226-
protected void finalize() throws Throwable {
227-
try {
228-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
229-
BidirectionalBinding.unbindNumber(this, DoubleProperty.this);
230-
return null;
231-
}, acc);
232-
} finally {
233-
super.finalize();
234-
}
235-
}
236-
237206
};
238207
}
239208

modules/javafx.base/src/main/java/javafx/beans/property/FloatProperty.java

-31
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
import javafx.beans.value.WritableFloatValue;
3232
import com.sun.javafx.binding.Logging;
3333

34-
import java.security.AccessControlContext;
35-
import java.security.AccessController;
36-
import java.security.PrivilegedAction;
37-
3834
/**
3935
* This class defines a {@link Property} wrapping a {@code float} value.
4036
* <p>
@@ -151,7 +147,6 @@ public static FloatProperty floatProperty(final Property<Float> property) {
151147
throw new NullPointerException("Property cannot be null");
152148
}
153149
return new FloatPropertyBase() {
154-
private final AccessControlContext acc = AccessController.getContext();
155150
{
156151
BidirectionalBinding.bindNumber(this, property);
157152
}
@@ -165,18 +160,6 @@ public Object getBean() {
165160
public String getName() {
166161
return property.getName();
167162
}
168-
169-
@Override
170-
protected void finalize() throws Throwable {
171-
try {
172-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
173-
BidirectionalBinding.unbindNumber(property, this);
174-
return null;
175-
}, acc);
176-
} finally {
177-
super.finalize();
178-
}
179-
}
180163
};
181164
}
182165

@@ -202,7 +185,6 @@ protected void finalize() throws Throwable {
202185
@Override
203186
public ObjectProperty<Float> asObject() {
204187
return new ObjectPropertyBase<Float> () {
205-
private final AccessControlContext acc = AccessController.getContext();
206188
{
207189
BidirectionalBinding.bindNumber(this, FloatProperty.this);
208190
}
@@ -216,19 +198,6 @@ public Object getBean() {
216198
public String getName() {
217199
return FloatProperty.this.getName();
218200
}
219-
220-
@Override
221-
protected void finalize() throws Throwable {
222-
try {
223-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
224-
BidirectionalBinding.unbindNumber(this, FloatProperty.this);
225-
return null;
226-
}, acc);
227-
} finally {
228-
super.finalize();
229-
}
230-
}
231-
232201
};
233202
}
234203

modules/javafx.base/src/main/java/javafx/beans/property/IntegerProperty.java

-31
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
import javafx.beans.value.WritableIntegerValue;
3232
import com.sun.javafx.binding.Logging;
3333

34-
import java.security.AccessControlContext;
35-
import java.security.AccessController;
36-
import java.security.PrivilegedAction;
37-
3834
/**
3935
* This class defines a {@link Property} wrapping an {@code int} value.
4036
* <p>
@@ -151,7 +147,6 @@ public static IntegerProperty integerProperty(final Property<Integer> property)
151147
throw new NullPointerException("Property cannot be null");
152148
}
153149
return new IntegerPropertyBase() {
154-
private final AccessControlContext acc = AccessController.getContext();
155150
{
156151
BidirectionalBinding.bindNumber(this, property);
157152
}
@@ -165,18 +160,6 @@ public Object getBean() {
165160
public String getName() {
166161
return property.getName();
167162
}
168-
169-
@Override
170-
protected void finalize() throws Throwable {
171-
try {
172-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
173-
BidirectionalBinding.unbindNumber(property, this);
174-
return null;
175-
}, acc);
176-
} finally {
177-
super.finalize();
178-
}
179-
}
180163
};
181164
}
182165

@@ -202,7 +185,6 @@ protected void finalize() throws Throwable {
202185
@Override
203186
public ObjectProperty<Integer> asObject() {
204187
return new ObjectPropertyBase<Integer> () {
205-
private final AccessControlContext acc = AccessController.getContext();
206188
{
207189
BidirectionalBinding.bindNumber(this, IntegerProperty.this);
208190
}
@@ -216,19 +198,6 @@ public Object getBean() {
216198
public String getName() {
217199
return IntegerProperty.this.getName();
218200
}
219-
220-
@Override
221-
protected void finalize() throws Throwable {
222-
try {
223-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
224-
BidirectionalBinding.unbindNumber(this, IntegerProperty.this);
225-
return null;
226-
}, acc);
227-
} finally {
228-
super.finalize();
229-
}
230-
}
231-
232201
};
233202
}
234203
}

modules/javafx.base/src/main/java/javafx/beans/property/LongProperty.java

-31
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
import javafx.beans.value.WritableLongValue;
3232
import com.sun.javafx.binding.Logging;
3333

34-
import java.security.AccessControlContext;
35-
import java.security.AccessController;
36-
import java.security.PrivilegedAction;
37-
3834
/**
3935
* This class defines a {@link Property} wrapping a {@code long} value.
4036
* <p>
@@ -149,7 +145,6 @@ public static LongProperty longProperty(final Property<Long> property) {
149145
throw new NullPointerException("Property cannot be null");
150146
}
151147
return new LongPropertyBase() {
152-
private final AccessControlContext acc = AccessController.getContext();
153148
{
154149
BidirectionalBinding.bindNumber(this, property);
155150
}
@@ -163,18 +158,6 @@ public Object getBean() {
163158
public String getName() {
164159
return property.getName();
165160
}
166-
167-
@Override
168-
protected void finalize() throws Throwable {
169-
try {
170-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
171-
BidirectionalBinding.unbindNumber(property, this);
172-
return null;
173-
}, acc);
174-
} finally {
175-
super.finalize();
176-
}
177-
}
178161
};
179162
}
180163

@@ -200,7 +183,6 @@ protected void finalize() throws Throwable {
200183
@Override
201184
public ObjectProperty<Long> asObject() {
202185
return new ObjectPropertyBase<Long> () {
203-
private final AccessControlContext acc = AccessController.getContext();
204186
{
205187
BidirectionalBinding.bindNumber(this, LongProperty.this);
206188
}
@@ -214,19 +196,6 @@ public Object getBean() {
214196
public String getName() {
215197
return LongProperty.this.getName();
216198
}
217-
218-
@Override
219-
protected void finalize() throws Throwable {
220-
try {
221-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
222-
BidirectionalBinding.unbindNumber(this, LongProperty.this);
223-
return null;
224-
}, acc);
225-
} finally {
226-
super.finalize();
227-
}
228-
}
229-
230199
};
231200
}
232201
}

0 commit comments

Comments
 (0)