JDK-4511903 : At times getWhen()in ActionEvent returns higher value than the CurrentSystemTime
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2001-10-08
  • Updated: 2006-08-16
  • Resolved: 2006-08-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Relates :  
Relates :  
Description
=========================================================
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)

Platforms : Windows , Solaris IA .

====================================================

I understand that getWhen() method in ActionEvent should always return a value that is lesser than the current System time .Correct me If I am wrong ?

Now when I run this test program , I observe that getWhen() sometimes returns a time that is higher than the current system time .

===================================================

Steps to reproduce this program :

1) Run this program .

2) when the frame comes up , Click on the Button .An action Event will be triggered and I am printing the values returned by getWhen() and 
the Current System time to the console. 

3) Click the Button 10 -15 times , you will observe that at some instants , the value returned by getWhen() is much higher than the 
current system time .(which should not be the case )


Test Program :
===========================================================

import java.awt.*;
import java.awt.event.*;

public class ActionEventTest extends Frame implements ActionListener{

        Frame frame;
        Button button;
        TextField textField;
        Toolkit toolkit ;

    public ActionEventTest() {

        frame=new Frame();
        frame.setTitle("Action Event Test");
        frame.setLayout(new FlowLayout());

        button=new Button("BUTTON");
        textField=new TextField(5);

        button.addActionListener(this);
	textField.addActionListener(this);

        frame.add(button);
        frame.add(textField);

        frame.setBackground(Color.red);
        frame.setSize(500,200);
        frame.setVisible(true);
        frame.toFront();
    }

    public void actionPerformed(ActionEvent ae) {


	long when = ae.getWhen();
        long current = System.currentTimeMillis();
        System.out.println("getWhen returns :"+ when);
        System.out.println("current returns :"+ current);
        if(when < current){
          System.out.println("getWhen is lesser than Current time ");
        }
        if(when  >= current){
          System.out.println("getWhen is greater than Current time ");
        }
        System.out.println("Param String is : " + ae.paramString());
	System.out.println("********************************");

    }

public static void main(String args[]){
  ActionEventTest avt = new ActionEventTest();

}
}

========================================================================


Note : This bug is not easily reproducable and you will have to click the button
 10 -15 times . This is easily reproducable in Windows/IA  for a few clicks .

Comments
EVALUATION The defect is not reproducible anymore after the fix 6183877.
16-08-2006

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
17-09-2004

EVALUATION will be filed by responsible engineer Name: osR10079 Date: 07/22/2003 The problem is (hardly) reproducible with 1.4, but it is not reproducible with 1.4.2 and current Tiger build. I suspect that timings have been changed. I have some idea which part of our code may cause the problem, but I would like do not change it because I will be unable to verify that the problem is fixed. ###@###.### 2003-07-22 ======================================================================
22-07-2003