Skip to content

Commit 3a73b77

Browse files
EcljpseB0Tjukzi
authored andcommitted
fix warning about Field.isAccessible()
'The method isAccessible() from the type AccessibleObject is deprecated since version 9'
1 parent 42ba0c2 commit 3a73b77

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ public ConstructorRequestor(Constructor<?> constructor, IInjector injector, Prim
3131
@Override
3232
public Object execute() throws InjectionException {
3333
Object result = null;
34-
if (!location.isAccessible()) {
35-
location.setAccessible(true);
36-
}
3734
boolean pausedRecording = false;
3835
if ((primarySupplier != null)) {
3936
primarySupplier.pauseRecording();
4037
pausedRecording = true;
4138
}
4239
try {
40+
location.trySetAccessible();
4341
result = location.newInstance(actualArgs);
44-
} catch (IllegalArgumentException | IllegalAccessException e) {
42+
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
4543
throw new InjectionException(e);
4644
} catch (InstantiationException e) {
4745
throw new InjectionException("Unable to instantiate " + location, e); //$NON-NLS-1$

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/FieldRequestor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ private boolean setField(Field field, Object value) throws InjectionException {
4444
Object userObject = getRequestingObject();
4545
if (userObject == null)
4646
return false;
47-
if (!field.isAccessible()) {
48-
field.setAccessible(true);
49-
}
5047
try {
48+
field.trySetAccessible();
5149
field.set(userObject, value);
52-
} catch (IllegalArgumentException | IllegalAccessException e) {
50+
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
5351
throw new InjectionException(e);
5452
}
5553
return true;

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,15 @@ public Object execute() throws InjectionException {
4646
if (userObject == null)
4747
return null;
4848
Object result = null;
49-
if (!location.isAccessible()) {
50-
location.setAccessible(true);
51-
}
5249
boolean pausedRecording = false;
5350
if ((primarySupplier != null)) {
5451
primarySupplier.pauseRecording();
5552
pausedRecording = true;
5653
}
5754
try {
55+
location.trySetAccessible();
5856
result = location.invoke(userObject, actualArgs);
59-
} catch (IllegalArgumentException | IllegalAccessException e) {
57+
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
6058
throw new InjectionException(e);
6159
} catch (InvocationTargetException e) {
6260
Throwable originalException = e.getCause();

0 commit comments

Comments
 (0)