Skip to content

Commit

Permalink
8257584: [macos] NullPointerException originating from LWCToolkit.java
Browse files Browse the repository at this point in the history
Made sure that accidentally passing null to the getAccessibleComponent()
or getAccessibleParent() does not cause any exceptions.
No tests since i cannot find a way to reproduce this issue without third
party system tools.
  • Loading branch information
azuev-java committed Dec 16, 2020
1 parent 16e32da commit 9a91254
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,31 @@ public void propertyChange(final PropertyChangeEvent evt) {
private native void focusChanged();

static <T> T invokeAndWait(final Callable<T> callable, final Component c) {
try {
return LWCToolkit.invokeAndWait(callable, c);
} catch (final Exception e) { e.printStackTrace(); }
if (c != null) {
try {
return LWCToolkit.invokeAndWait(callable, c);
} catch (final Exception e) { e.printStackTrace(); }
}
return null;
}

static <T> T invokeAndWait(final Callable<T> callable, final Component c, final T defValue) {
T value = null;
try {
value = LWCToolkit.invokeAndWait(callable, c);
} catch (final Exception e) { e.printStackTrace(); }
if (c != null) {
try {
value = LWCToolkit.invokeAndWait(callable, c);
} catch (final Exception e) { e.printStackTrace(); }
}

return value != null ? value : defValue;
}

static void invokeLater(final Runnable runnable, final Component c) {
try {
LWCToolkit.invokeLater(runnable, c);
} catch (InvocationTargetException e) { e.printStackTrace(); }
if (c != null) {
try {
LWCToolkit.invokeLater(runnable, c);
} catch (InvocationTargetException e) { e.printStackTrace(); }
}
}

public static String getAccessibleActionDescription(final AccessibleAction aa, final int index, final Component c) {
Expand Down

0 comments on commit 9a91254

Please sign in to comment.