equal
deleted
inserted
replaced
33 import java.util.concurrent.atomic.AtomicBoolean; |
33 import java.util.concurrent.atomic.AtomicBoolean; |
34 import java.util.concurrent.locks.*; |
34 import java.util.concurrent.locks.*; |
35 import java.awt.*; |
35 import java.awt.*; |
36 import java.awt.event.*; |
36 import java.awt.event.*; |
37 import java.io.Serializable; |
37 import java.io.Serializable; |
|
38 import java.io.*; |
|
39 import java.security.AccessControlContext; |
|
40 import java.security.AccessController; |
|
41 import java.security.PrivilegedAction; |
38 import javax.swing.event.EventListenerList; |
42 import javax.swing.event.EventListenerList; |
39 |
43 |
40 |
44 |
41 |
45 |
42 /** |
46 /** |
206 if (listener != null) { |
210 if (listener != null) { |
207 addActionListener(listener); |
211 addActionListener(listener); |
208 } |
212 } |
209 } |
213 } |
210 |
214 |
|
215 /* |
|
216 * The timer's AccessControlContext. |
|
217 */ |
|
218 private transient volatile AccessControlContext acc = |
|
219 AccessController.getContext(); |
|
220 |
|
221 /** |
|
222 * Returns the acc this timer was constructed with. |
|
223 */ |
|
224 final AccessControlContext getAccessControlContext() { |
|
225 if (acc == null) { |
|
226 throw new SecurityException( |
|
227 "Timer is missing AccessControlContext"); |
|
228 } |
|
229 return acc; |
|
230 } |
211 |
231 |
212 /** |
232 /** |
213 * DoPostEvent is a runnable class that fires actionEvents to |
233 * DoPostEvent is a runnable class that fires actionEvents to |
214 * the listeners on the EventDispatchThread, via invokeLater. |
234 * the listeners on the EventDispatchThread, via invokeLater. |
215 * @see Timer#post |
235 * @see Timer#post |
585 notify.set(false); |
605 notify.set(false); |
586 } |
606 } |
587 |
607 |
588 |
608 |
589 void post() { |
609 void post() { |
590 if (notify.compareAndSet(false, true) || !coalesce) { |
610 if (notify.compareAndSet(false, true) || !coalesce) { |
591 SwingUtilities.invokeLater(doPostEvent); |
611 AccessController.doPrivileged(new PrivilegedAction<Void>() { |
|
612 public Void run() { |
|
613 SwingUtilities.invokeLater(doPostEvent); |
|
614 return null; |
|
615 } |
|
616 }, getAccessControlContext()); |
592 } |
617 } |
593 } |
618 } |
594 |
619 |
595 Lock getLock() { |
620 Lock getLock() { |
596 return lock; |
621 return lock; |
|
622 } |
|
623 |
|
624 private void readObject(ObjectInputStream in) |
|
625 throws ClassNotFoundException, IOException |
|
626 { |
|
627 this.acc = AccessController.getContext(); |
|
628 in.defaultReadObject(); |
597 } |
629 } |
598 |
630 |
599 /* |
631 /* |
600 * We have to use readResolve because we can not initialize final |
632 * We have to use readResolve because we can not initialize final |
601 * fields for deserialized object otherwise |
633 * fields for deserialized object otherwise |