From 13434e1121e7f745964b5e1d67f1bc1d0960213f Mon Sep 17 00:00:00 2001 From: duncanmcqueen Date: Wed, 14 Oct 2026 08:26:59 -0500 Subject: [PATCH] Accept valid source actions in drop target events DropTargetDragEvent and DropTargetDropEvent tested the source actions with ~(actions ^ mask) != 0. That test is true for every value except ~mask, so both constructors threw IllegalArgumentException for all valid actions, for example ACTION_COPY_OR_MOVE. Reject only bits that are not in the mask. Co-Authored-By: Claude Opus 5.5 Signed-off-by: duncanmcqueen --- java/awt/dnd/DropTargetDragEvent.java | 2 +- java/awt/dnd/DropTargetDropEvent.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/awt/dnd/DropTargetDragEvent.java b/java/awt/dnd/DropTargetDragEvent.java index 21c9e2b35c..db06c237d1 100644 --- a/java/awt/dnd/DropTargetDragEvent.java +++ b/java/awt/dnd/DropTargetDragEvent.java @@ -90,7 +90,7 @@ public DropTargetDragEvent (DropTargetContext context, Point location, | DnDConstants.ACTION_LINK | DnDConstants.ACTION_REFERENCE; - if (~(srcActions ^ srcActionsMask) != 0) + if ((srcActions & ~srcActionsMask) != 0) throw new IllegalArgumentException (); this.dropAction = dropAction; diff --git a/java/awt/dnd/DropTargetDropEvent.java b/java/awt/dnd/DropTargetDropEvent.java index 333f8c6cc5..9944ec9558 100644 --- a/java/awt/dnd/DropTargetDropEvent.java +++ b/java/awt/dnd/DropTargetDropEvent.java @@ -104,7 +104,7 @@ public DropTargetDropEvent(DropTargetContext dtc, Point location, | DnDConstants.ACTION_LINK | DnDConstants.ACTION_REFERENCE; - if (~(actions ^ actionsMask) != 0) + if ((actions & ~actionsMask) != 0) throw new IllegalArgumentException(); this.dropAction = dropAction;