JFrame maximizing - non deterministic behaviour

Hi there,
I wonder why in the following code the componentResized Method gets a JFrame instance wthich's extended state is MAX_BOTH and the componentMoved Method NORMAL.
Does someone have an explanation or an work around for storing the last position of the JFrame (to store in preferences in order to load them again).
Here is a minimal example.
import javax.swing.JFrame;
* @author Karlheinz Toni
public class Test {
    public static void main(String[] args) {
        JFrame mainFrame = new JFrame();
        mainFrame.addComponentListener(new ComponentAdapter() {
             * (non-Javadoc)
             * @see java.awt.event.ComponentAdapter#componentMoved(java.awt.event.ComponentEvent)
            public void componentMoved(ComponentEvent e) {
                // TODO Auto-generated method stub
                super.componentMoved(e);
                printExtendedState(e.getComponent(), "moving");
             * (non-Javadoc)
             * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
            public void componentResized(ComponentEvent e) {
                // TODO Auto-generated method stub
                super.componentResized(e);
                printExtendedState(e.getComponent(), "resizing");
            private void printExtendedState(Component component,
                    String whatDoIDo) {
                if (component instanceof JFrame) {
                    System.out.println("Extended state for " + whatDoIDo + ":"
                            + ((JFrame) component).getExtendedState());
        mainFrame.setVisible(true);
}I would be greatful to any help ;)
Sincerely
Charly

I was playing with exactly this kind of thing last night and discovered that the order you get the events isn't really guaranteed. I solved this by using a swing Timer to wait for 1 second of inactivity before querying the Frame and updating the user preferences. Here's the chopped down version of my code:
I register a GeometryTracker object as a ComponentListener and a WindowStateListener in the frame to be monitored.
This all seems to work quite well, but I'm still seeing differences between windows and OS-X for example. (on OS-X the maximized state doesn't seem to correlate with reality. If anyone knows of a trick I'd love to see it.
Thanks and I hope this helps!
Cheers,
Seve
import javax.swing.Timer;
public class GeometryTracker
    extends ComponentAdapter
    implements WindowStateListener
    private Frame       frame;
    private Preferences framePrefs;
    private int         frameState = 0;
    private Rectangle   frameBounds;
    private Timer       updateTimer;
    // TODO: problem with setting up the preferences once like this: changes to screen size aren't handled
    public GeometryTracker( Frame targetFrame ) {
        frame                  = targetFrame;
        framePrefs             = Preferences.userNodeForPackage( frame.getClass() );
        frameState             = frame.getExtendedState();
        frameBounds            = frame.getBounds();
        updateTimer            = new Timer( 1000, new AbstractAction() { public void actionPerformed( ActionEvent e ) { updatePrefs(); } } );
    private synchronized void updatePrefs() {
        frameState = frame.getExtendedState();
        // don't update the window size/location if it has been maximized
        if( ( frameState & Frame.MAXIMIZED_BOTH ) == 0 ) {
            frameBounds = frame.getBounds();
        framePrefs.putInt( "x",      frameBounds.x      );
        framePrefs.putInt( "y",      frameBounds.y      );
        framePrefs.putInt( "width",  frameBounds.width  );
        framePrefs.putInt( "height", frameBounds.height );
        framePrefs.putInt( "state",  frameState         );
        updateTimer.stop();
    public void setBounds( Rectangle defaultBounds ) {
        Rectangle r = new Rectangle();
        r.x         = framePrefs.getInt( "x",      defaultBounds.x      );
        r.y         = framePrefs.getInt( "y",      defaultBounds.y      );
        r.width     = framePrefs.getInt( "width",  defaultBounds.width  );
        r.height    = framePrefs.getInt( "height", defaultBounds.height );
        frameState  = framePrefs.getInt( "state",  Frame.NORMAL );
        frame.setBounds( r );
        if( ( frameState & Frame.MAXIMIZED_BOTH ) != 0 ) {
            frame.setExtendedState( frameState );
    public void componentMoved( ComponentEvent e ) {
        updateTimer.setDelay( 1000 );
        updateTimer.start();
    public void componentResized( ComponentEvent e ) {
        updateTimer.setDelay( 1000 );
        updateTimer.start();
    public void windowStateChanged( WindowEvent e ) {
        updateTimer.setDelay( 1000 );
        updateTimer.start();
    }

Similar Messages

  • Using a 2-D array Single Process Shared Variable w/ RT FIFO for comm between a Deterministic and non-deterministic loop on an RT Target

    Our problem is that we currently use a 2D array to store CAN data on a Real-time Target. The array is 20 elements of 3 byte elements as so:
                    0              1              2
    0              [byte]   [byte]   [byte]
    19           [byte]   [byte]   [byte]
    These values are passed between a Deterministic Timed (DT) loop where they are set and a Non-Deterministic Timed (NDT) loop where they are read and passed into a Network Published Shared Variable (NPSV) for communication across the network to a Host PC. I have insrted an image for illustration, pardon the size.
    Currently to pass the data between the DT and NDT loop we are using a Global Variable (GV). To improve the system we have attempted to replace these GVs with Single Process Shared Variables (SPSV) with an RT FIFO enabled.
    To create the shared variable I simply right clicked the GV of interest and selected create Shared Variable Node form the drop downs. At this point LabVIEW presented me with a 2D NPSV within a new Library hosted on the RT Target. I then selected this new NPSV from the Project, changed it to a SPSV, and enabled a single element FIFO. This variable was initialized with a default value for the size described above and then used in our code for the DT to NDT communication, and conversion to a corresponding NPSV for sending to the Host.
    When I went to run the code I noticed that the variable was in fact 2D, however its size was only 2 elements of three bytes each, in other words only two of the row indices were populated and the other appeared as uninitialized. in addition, this data had no resemblance to the set initilazation value. This was also how the variable was presented on the host side of the network after tranfer into a NPSV.
    The peculiar part is that If I change this SPSV to a NPSV and then try to change it back, I receive an error saying the type is not supported for SPSV with an RT FIFO enabled. I have to disable the FIFO (which defeats the entire purpose) in order to successfully compile! I am unclear as to what is the bug in this case. Should I not be allowed to create the original 2D SPSV with a single element RT FIFO enabled without receiving an error? Or if this is okay how do I fix the problems associated with the variable after being allowed to create it?
    I have found the following discussion in which a user states “The only limitations for custom controls is the ability to use it with RT FIFO enabled on a network-published shared variable”. Is this also true for SPSV? I have not found any documentation explicitely stating this for SPSV, though it is stated for the NPSVs.

    Martin,
    RT FIFOs don't support Multi-Dimensional Arrays, which would corroborate the issues you're seeing.  You can break up the 2D array into 1D arrays by reshaping the array, then you'll be able to use the RT FIFO enabled variable, just set the array size to the total number of elements (20*3 = 60).
    You can also pass the 2D array via pre-allocated queue, or using a Functional Global.  We have a reference example for a circular buffer using Functional Globals here.

  • How can I change a decorated JFrame to non-decorated JFrame?

    I want to change a decorated JFrame to a non-decorated JFame. The frame already shown on the screen. How can I do this?

    If I call dispose() and setVisible(), the window ID will be changed. I am working on Linux and need to communicate with other processes by window ID. Is there a method to set a frame decorate without change window ID?

  • JFrame -- maximized window

    Hi,
    does anyone know, how to maximize JFrame window?
           JFrame frame = new JFrame();
    //        frame.pack();
            frame.setSize(  ???  );
            frame.setVisible(true);Thanks in advance. Lokutus.

    Another approach:
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);although I'm not sure this will work on all platforms. This way has the additional advantage that the frame will be "truly" maximized, i.e. its maximize/restore button will be updated.

  • Make the jframe maximized

    Hi,
    I tried this code
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setSize( screenSize.width, screenSize.height - 80 );
    frame.validate();
    and the jframe is now almost cover the whole screen, the problems are
    - I need to substract with 80, since otherwise my windows toolnar will cover the frame.
    - In macosx it is ok but some parts of the table on the bottom of the jframe looks like cut.
    Is there any simple way to make the screen maximized?
    Thank for the help.
    Daniel

    Dear Andrew,
    Thank you for the quick response. Agree, code snippets would be readable if we put them inside . Apologise for the mistake.
    Once again, thanks a lot.                                                                                                                                                                                                                                                                                                                                                   

  • JFrame.setVisible(boolean) -- strange behaviour

    I have a class derived from JFrame, (not set visible by default)
    and a global instance of it, initialised by an other classe's constructor.
    Problem:
    Whenever I invoke its setVisible from this constructor, it works fine,
    but called from the same classe's actionPerformed, it doesn't display its contents, only an empty JFrame.
    Details:
    The custom caption is always correctly displayed.
    The contents is a JPanel containing a JLabel, and both are correct all the time (println before & after setVisible).
    There are no NullPointerExceptions.
    Sure I do a lot of computing while displaying, and println works pretty slowly, too, but I don't think this would be the problem.
    What could be the reason?

    yes, I have made a source containig only the problematic part,
    and this one works the same way as my whole project:
    // this is the contents of WindowFrame.java:
    import javax.swing.*;
    import java.awt.*;
    class WindowFrame extends JFrame
      public WindowFrame()
        super("my window");
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        setLocationRelativeTo(null);
        setResizable(false);
        JPanel jp = new JPanel();
        jp.setLayout(new BorderLayout());
        jp.setBackground(Color.white);
        jp.add(new JLabel("this is the contents of this window"));
        getContentPane().add(jp);
        pack();
    // *************end of WindowFrame.java
    // And this one is the MainPanel.java:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class MainPanel extends JPanel implements ActionListener
      private String ButtonPressed = "ButtonPressed";
      private WindowFrame Wfr = null;
      public MainPanel()
        setLayout(new BorderLayout());
        JButton jb = new JButton("my button");
        jb.setActionCommand(ButtonPressed);
        jb.addActionListener(this);
        Wfr = new WindowFrame();
        Wfr.setVisible(true);
        // some computing, for example:
        for(long j = 0; j < 10000; j ++) for(long i = 0; i < 10000; i ++);
        Wfr.setVisible(false);
        add(jb);
      public void actionPerformed(ActionEvent e)
        if(e != null)
          String s = e.getActionCommand();
          if(s != null)
            if(s.equals(ButtonPressed) && Wfr != null)
              Wfr.setVisible(true);
              // some computing, for example:
              for(long j = 0; j < 10000; j ++) for(long i = 0; i < 10000; i ++);
              Wfr.setVisible(false);
      public static void main(String[] s)
        JFrame jf = new JFrame("test for MainPanel");
        MainPanel mp = new MainPanel();
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setLocation(100, 100);
        jf.setSize(400, 400);
        jf.getContentPane().add(mp);
        jf.setVisible(true);
    // ******** End of all MainPanel.javaThis produces all the same phenomena.

  • JFrame maximized bounds

    Hi! I'm using a JFrame in a game I'm developing, and this should be resizeable within some bounds. This works fine for the minimum size, the user is unable to even try to resize the frame smaller than what I've set as the minimum size. But it seems like maximum size is a different issue - I can't find a way to bound how large the user may expand the frame. Of course, when it's extended to a larger size than my specified maximum, it's resized back to the maximum size (using a ComponentListener to detect resize attempts - this has to be done because I need a constant aspect ratio - and a maximum size). But I don't like this solution very much, I would rather find it impossible to even try to extend the frame larger than the bounds - in the same way one can set the bounds for the minimum size. Please help me!
    Any suggestions anyone?
    PS: I have tried with setMaximumSize and setMaximizedBounds...

    When cross posting, please mention that on both threads. As this is better suited to this forum, I'm reposting the solution offered on the other thread.
    See [http://forums.sun.com/thread.jspa?threadID=5342801]
    The real issue is that setMinimumSize is declared in Window whereas setMaximumSize is declared in Component. Thus the two methods do not have complementary connotations.
    Experimenting with workarounds posted on those bug report pages, I think this is the cleanest solution, even if it does involve using a painting method for something other than painting -- normally to be avoided. SSCCE:
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Point;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class MaxSizeFrame {
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new MaxSizeFrame().makeUI();
       public void makeUI() {
          final JFrame frame = new JFrame("") {
             @Override
             public void paint(Graphics g) {
                Dimension d = getSize();
                Dimension m = getMaximumSize();
                boolean resize = d.width > m.width || d.height > m.height;
                d.width = Math.min(m.width, d.width);
                d.height = Math.min(m.height, d.height);
                if (resize) {
                   Point p = getLocation();
                   setVisible(false);
                   setSize(d);
                   setLocation(p);
                   setVisible(true);
                super.paint(g);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(400, 400);
          frame.setMaximumSize(new Dimension(500, 500));
          frame.setMinimumSize(new Dimension(300, 300));
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
    }This way, instead of repeated flickering, there is just one flicker as the specified maximum size is crossed.
    db

  • Non-deterministic NoSuchObjectException

    Hi,
    In my source code I export a remote object using UnicastRemoteObject.export(remoteObject, rmiPort) and bind it to a RMI service name using Naming.rebind(serviceName, remoteObject).
    About 40 client instances successfully use this exported RMI object (they are running on two different hosts). But now and then a client can initially use the exported RMI object but after some time (1 minute) an java.rmi.NoSuchObjectException is thrown when a method of the remote object is called. If the client is closed and another client instance is started everything is fine again.
    The application exporting the remote object is not restarted or anything else in the meantime. In addition, I only unexport the remote object manually when the application is shut down.
    Could it be be a Distributed Garbage Collection problem? What can be the possible reasons that a remote object gets unavailable just for one single client?
    thanks for any help

    I have one main entry point (a remote object exported
    and bound to the registry) to my RMI application that
    all clients use. Every client then gets an own remote
    object instance from this main entry point. The
    problem is that the NoSuchObjectException is thrown
    when trying to access the main entry point (not the
    single remote object instances for the clients).Ok, then you can recover from that by repeating the lookup and retrying using the new stub. If that fails, bail out.
    If the exported remote object gets DGCd then how is
    it possible that I can use the remote object again if
    I start a new client instance?No idea.
    It seems as if the remote stub gets DGCd (although
    bound to a RMI service name).Possible but unlikely given the Registry and the server JVM are coresident in the same host.
    But after performing a
    new RMI service lookup (by starting a new client
    instance) a remote stub is available again.Exactly, see above.
    Does the RMI Registry implement a mechanism for generating new
    stub objects if none exists for an exported and bound
    remote object?Definitely not.
    Info: I don't hold a reference to the exported stub object.I don't know what the 'exported stub object' is. Do you mean that the server JVM doesn't hold local references to the per-client objects?

  • Disable JFrame under non Windows OS

    Hi,
    how can I disable a JFrame to prevent its usage (including close). The simple idea frame.setEnabled(false) does not work on Linux/Mac (both JDK1.4.x).
    1) setEnable(false) does not cascades through the nested components (works on Linux but no on Mac) - Ok I can do this manual
    2) I can close the frame via the system menu.
    Sample code:
    class TestFrame extends JFrame
      private int orgDefaultCloseOperation;
      public TestFrame(String title) {
        super(title);
        // init
        orgDefaultCloseOperation = getDefaultCloseOperation();
      public void setEnabled(boolean b) {
        enableComponts(b);
        if( b ) {
          getClassPane().setCursor(DEFAULT_CURSOR);
          getClassPane().setVisible(false);
          setDefaultCloseOperation(orgDefaultCloseOperation);
        } else {
          getClassPane().setCursor(WAIT_CURSOR);
          getClassPane().setVisible(true);
          orgDefaultCloseOperation = getDefaultCloseOperation();
          setDefaultCloseOperation(DO_NOTHING_ONCLOSE); // should ignore system respons
        super.setEnabled(b);
      private void enableComponents() {
    }Thanks in advance,
    Sven

    Some code to get you started:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
        public Test () {
            super ("Test");
            getContentPane ().add (new JLabel ("Test", SwingConstants.CENTER));
            setDefaultCloseOperation (DO_NOTHING_ON_CLOSE);
            addWindowListener (new WindowAdapter () {
                public void windowClosing (WindowEvent event) {
                    if (JOptionPane.showConfirmDialog (Test.this, "Are you sure you want to quit?") == JOptionPane.YES_OPTION) {
                        System.exit (0);
            pack ();
            setLocationRelativeTo (null);
            show ();
        public static void main (String[] parameters) {
            new Test ();
    }Kind regards,
      Levi

  • ITunes 8 'odd non-responsive behaviour' when trying to log in to Store

    Whenever I try and use any of the functions of iTunes 7.x or 8 and the iTunes store (e.g. signing in an account, attempting to create a new account) or enabling Genius in iTunes 8, iTunes becomes unresponsive in a distinctly odd fashion.
    I can still access the iTunes store, browse music etc., but anything that requires authentication, it seems, causes the store to stop responding. Once thestore has decided to become unresponsive, I can't browse the store any further, but can still use the rest of iTunes (e.g. my own library...) The 'information window' (for want of a better word: where song information is usually displayed at the top centre of the iTunes window) shows "Accessing iTunes Store..." and the crosshatched progress bar, which then doesn't change into the solid progress bar as normal. iTunes can be used normally, but refuses to close, and requires Task Manager to kill it.
    I'm running iTunes 8 on Win XP SP 2 (originally iTunes 7.x, which had the same problem -- I had naively thought an upgrade might fix it!). I've tried simple things like disabling the Windows Firewall, don't to the best of my knowledge have any other firewalls running, and have tried killing anything other than the vital system processes in Task Manager and the Windows Services Viewer thingy.
    I must admit to being slightly worried: my new iPhone arrives in a few days and I'd quite like to be able to get the App Store etc running...!
    (edited to add: I've tried running the iTunes network diagnostics, which crashed iTunes properly, to the point at which the whole program stopped responding and needed killing in Task Manager -- I'm sorry that's not going to be much use..!)
    Message was edited by: srg40

    ive been having odd behavior for my itune store too. whenever i try to access it, all the info loads like normal but if i click on any thing it freaks out and all the info for the songs and everything just freaks out. it becomes like it was made by a five year old on microsoft word. there are no images, there is only a picture of a link of chain and one of the chains is broken. i can still read the title, the price and the artist but, they are all in a wierd font size.
    i still have access to everything but i am reluctant to click on anything because i dont want it to spread to my itunes. this just started today and was working fine before
    is there anything i can do about it and it it safe for me to do anything?

  • Bizzarre non-deterministic run-time behavior.

    This is an attempt to coninue a thread that fell into the Archived Forums category after a year of inactivity. That thread can no longer be updated.
    This post is merely to note that the bug encountered in
    http://forum.java.sun.com/thread.jspa?threadID=463092
    was finally fixed by the JDK 1.4.2_06 . This fact is also documenter here:
    http://java.sun.com/j2se/1.4.2/ReleaseNotes.html
    BugID: 4917709: SEGV in MapLoops test      
    Java release version: 1.4.2_06, all platforms

    Duh! I now see that this fact is available in the Bug Parade.

  • Non-deterministic photo adjust settings

    This is a slightly technical question. I'm just starting to use iPhoto '08 to touch up my photos and adjust things such as exposure, highlights, shadows, temperature, etc. For example, I want to adjust the highlights, so I'll move the slider in 10% increments (ie, drag the slider 10 and release, drag another 10 and release, and so on so that each operation is saved in the Undo/Redo buffer). Then, I can use Undo/Redo to quickly move back and forth along these increments and see which I like better. However, what I've noticed by looking at the RGB histogram is that moving from 10 to 20 results in a slightly different histogram change than moving from 30 to 20. Can someone explain what's going on and why 20 will look different depending on whether it's an Undo or Redo action? Thanks for any insights.

    I just ran a test and confirmed your observations. However, if you save the change at 20, going to 30 and undoing will result in the same histogram.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier versions) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. There are versions that are compatible with iPhoto 5, 6, 7 and 8 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    NOTE: The new rebuild option in iPhoto 09 (v. 8.0.2), Rebuild the iPhoto Library Database from automatic backup" makes this tip obsolete.

  • Non-Deterministic Exception When Connecting With Wrong Client Certificate

    I am working on an internal application and need to determine the correct client-side SSL certificate to use when connecting to a server (the user can supply multiple client-side certificates). I had expected that if I connected to a server using the wrong client certificate the java client would throw a SSLHandshakeException and I could then try the next certificate. This seems to work some of the time, however the java client will sometimes throw a “SocketException: Software caused connection abort: recv failed”, in which case it is not possible to know that the wrong certificate caused the problem.
    Below is the code I have been using to test as well as the intermittent SocketException stack trace. Does anyone have an idea as to how to fix this problem? Thanks in advance.
    Note: the TrustAllX509TrustManager is a trust manager that trusts all servers.
    protected void connectSsl() throws Exception {
          final String host = "x.x.x.x";
          final int portNumber = 443;
          final int socketTimeout = 10*1000;
          // Note: Wrong certificate (expect SSLHandshakeException).
          final String certFilename = "C:\\xxx\\clientSSL.P12";
          final String certPassword = "certPassword";
          final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(certFilename)));
          final char[] certificatePasswordArray = certPassword.toCharArray();
          final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
          final KeyStore keyStore = KeyStore.getInstance("PKCS12");
          keyStore.load(bis, certificatePasswordArray);
          keyManagerFactory.init(keyStore, certificatePasswordArray);
          final KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
          final SSLContext context = SSLContext.getInstance("SSL");
          context.init(keyManagers, new TrustManager[]{new TrustAllX509TrustManager()}, new SecureRandom());
          final SocketFactory secureFactory = context.getSocketFactory();
          final Socket socket = secureFactory.createSocket();
          final InetAddress ip = InetAddress.getByName(host);
          socket.connect(new InetSocketAddress(ip, portNumber), socketTimeout);
          socket.setSoTimeout(socketTimeout);
          // Write the request.
          final OutputStream out = new BufferedOutputStream(socket.getOutputStream());
          out.write("GET / HTTP/1.1\r\n".getBytes());
          out.write("\r\n".getBytes());
          out.flush();
          InputStream inputStream = socket.getInputStream();
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
          byte[] byteArray = new byte[1024];
          int bytesRead = 0;
          while ((bytesRead = inputStream.read(byteArray)) != -1) {
             outputStream.write(byteArray, 0, bytesRead);
          socket.close();
          System.out.println("Response:\r\n" + outputStream.toString("UTF-8"));
       }Unexpected SocketException:
    main: java.net.SocketException: Software caused connection abort: recv failed
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
         at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:789)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1435)
         at com.sun.net.ssl.internal.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:103)
         at com.sun.net.ssl.internal.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:612)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:808)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:734)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:197)
         at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
         at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
         at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
         at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

    Thanks for the quick response. Here are answers to the questions:
    1) No, this issue is not associated with one particular certificate. I have tried several certificates and see the same issue.
    2) I agree it would be simpler to only send the required certificate, but unfortunately the project requires that the user be able to specify multiple certificates and, if a client-side certificate is required, the application try each one in turn until the correct certificate is found.
    3) Yes, I realize the TrustAllX509TrustManager is insecure, but I am using this for testing purposes while trying to diagnose the client certificate problem.
    In terms of testing, I am just wrapping the above code in a try/catch block and executing it in a loop. It is quite odd that the same exact code will sometimes generate a SSLHandshakeException and other times a SocketException.
    One additional piece of information: if I force the client code to use "SSLv3" using the Socket.setEnabledProtocols(...) method, the problem goes away (I consistently get a SSLHandshakeException). However, I don't think this solves my problem as forcing the application to use SSLv3 would mean it could not handle TLS connections.
    The code to specify the SSLv3 protocol is:
    SSLSocket sslSocket = (SSLSocket) socket;
    sslSocket.setEnabledProtocols(new String[] {"SSLv3"});
    One other strange issue: if instead of specifying the SSLv3 protocol using setEnabledProtocols(...) I instead specify the protocol when creating the SSLContext, the SocketException problem comes back. So if I replace:
    final SSLContext context = SSLContext.getInstance("SSL");
    with:
    final SSLContext context = SSLContext.getInstance("SSLv3");
    and remove the "sslSocket.setEnabledProtocols(new String[] {"SSLv3"})" line, I see the intermittent SocketException problem.
    All very weird. Any thoughts?

  • Non deterministic FPGA - MCU interface (data bus)?

    Hello,
       Working on a learner project. ..  Using a Digilent Spartan 3A dev board where I have implimented counters for rotary encoder signals.  The counters seem correct as they are accurate for measuring displacement (distance/rotations).  The counters are presente to my MCU (LPC1769 Cortex M3) via GPIO...  16bit "data bus and 4bit "address bus".
       On a 1Khz interrupt, the MCU will write the address lines, delay 1us, and read the 16 bits data (GPIO) connected to the FPGA.  For testing, a function gereator is providing a consistent  signals to the FPGA with no physical encoders ,so I know the what the counter data shoud be.  However, the counter data being read from the FPGA has too much inconsistency and smells like a classic determinism problem.  
       I'm thinking the problem is in my verilog implimentation of the bus, shown here:
    module FPGA_Interface(
    input [3:0] Signals,
    input CLK_50M,
    input [3:0] Addr,
    output Valid,
    output wire [15:0] Data
    //Use of 'Valid' for handshaking is TBD
    assign Valid = 1'b0;
    wire [15:0] CountData0;
    wire [15:0] CountData1;
    //create two counters for the rotary encoders
    QuadratureCounter counter0(.EncSig(Signals[1:0]),.CLK_50M(CLK_50M),.CountData(CountData0) );
    QuadratureCounter
    counter1(.EncSig(Signals[3:2]),.CLK_50M(CLK_50M),.CountData(CountData1) );
    assign Data = (Addr == 4'b0000)? ~CountData0:
    (Addr == 4'b0001)? ~CountData1:
    (Addr == 4'b0010)? ~16'b0000000000000010:
    (Addr == 4'b0011)? ~16'b0000000000000011:
    16'b0000000000000111;
    endmodule
          Perhaps I should "latch" the data  to eliminate the potential of the data changing at read time? Any feedback on the design of the "data bus" would be grealy appreciated. Thanks,

    aszeghy wrote:
    Thank you bassman59 for the explanation.  Understood, now at least, this is a design problem. Although, I originally wanted to gate or "latch" the counter data so that it can be reliably ready by the MCU.  I thought I was getting that by latching the count data when the address lines changed state...  Apparently not.  This further confuses me.
    Looking at this academic mux example I see:
    always @ (posedge clk )
    if (reset == 0) begin
    y <= 0;
    end else if (sel == 0) begin
    y <= a;
    end else begin
    y <= b;
    end
    Now in this synthesised mux module y is updated on the positive edge of clk. Is y updated on a change to a or b?   If y is not updated then the sensitivity list has not been ignored.
    Is this because my code's sensitivity list suggested a change of state (combinational) and the text book example suggests a rising edge (sequential)?
    Thanks again for the education,
    Andrei
    In the code above you used the template for a register (flip-flop). 
    To answer your question, y is updated only on the event in the sensitivity list. Now, that statement is true for all always blocks. It was true for your initial address-decoder example, too, because as you discovered in simulation, the Data output did not change when the counter value changed, it changed only when there was an event on Addr (when the address changed).
    Now, please note my use of the word "template" above. At its core, synthesis is all about template matching, meaning that the synthesizer looks for specific patterns in your code when deciding what sort of logic to infer. And for the case where you would like to infer registers, the template demands that you put only the clock edge detector on the sensitivity list. Why? Because in a real flip-flop, what happens on the D input isn't interesting until a clock edge occurs.
    And that is what happens here. In simuation, everything on the right-hand-side of the assignments are ignored until there is an event which matches what is on the sensitivity list. In this case, the event of interest is the rising edge of the clock. At that moment, all right-hand-sides (which include the conditionals like if, case, etc) are evaluated and then the y output is assigned.
    In the real flipflop inferred by the synthesizer, that too is what happens. This is why for a synchronous block where you are inferring a register there is no simulation/synthesis mismatch when only the clock is on the sensitivity list.

  • Long.toString(long, int) throws ArrayIndexOutOfBoundsException

    We're using Long.toString(long, int) to convert a long into a base-32 string, which is used as a primary key for entities in our database. On occasion, Long.toString(long, int) throws an ArrayOutOfBoundsException! This only occurs in the deployed system, I cannot get it to occur in a testing environment.
    The object that contains the call to Long.toString(int, long) is shared by multiple threads, but the state of the object is immutable and access to the object is not synchronized. I have tested this code extensively with multithreaded access and cannot reproduce the exception in a test environment.
    Furthermore, this bug only occurs on Linux.
    As a workaround, we have a loop that will attempt the call 5 times, and then fail if the call could not be completed. Generally, this helps to get the code running but will sometimes fail.
    Here are some characteristics of the problem:
    1) Linux kernel 2.4.10 on Pentium III.
    2) Sun JVM 1.3.1_01
    3) Code is accessed from a session bean deployed into JBoss 2.4.3.
    4) Database entities have undergone bytecode enhancement per JDO specification.
    Obviously, the bytecode enhancement is most suspect here. The class that contains the error-prone code is not enhanced, but entities do contain references to instances of the primary key class.
    At first blush this sounds like a classic memory corruption issue that is surfacing in Long.toString() but is probably caused elsewhere. Has anybody seen anything like this or know of either a solution or suggested debugging procedure?
    Thanks.
    -brian

    We already discussed that approach. The reason that
    it was rejected is because my C experience suggests
    that it will just move the corruption evidence to another
    area of the application with possibly more insidious
    effects.I'm not so sure about that. Does your five-try loop actually help? If a stateless method throws an IndexOutOfBoundsException with a given set of parameters, then I would expect it to always throw this exception with the same parameters. Any other behaviour is non-deterministic and not suitable (IMHO) for a production machine.
    I assume you are manipulating arrays in other locations of your code... if these other locations aren't displaying similar non-deterministic behaviour, then common sense dictates that writing your own toString method will not exhibit the same non-deterministic behaviour.
    A little test, compile a class (TestLong, for argument sake) with the method exactly from the Sun source. Decompile it to byte-code with 'javap -c TestLong', and compare that to the same method from Long with 'javap -c java.lang.Long'. If the bytecode isn't identical (Barring numbering differences for class reference table differences), then the implementation you have is not the expected.
    A final suggestion, try a different JVM - both IBM and Sun provide JVMs for linux?

Maybe you are looking for

  • Mail - Deletion of Mail e-mails

    Trying to delete a number of e-mails using delete icon; the e-mails initally clear but on re-use find that the deleted e-mails are still present on the system. Any ideas on how to delete deleted e-mails!!!

  • BC sets to SAP BW

    Hello   Can we extract data from BC sets (Business Configuration sets) into the SAP BW. Thanks in advance Regards Shiva

  • Collaboration Room - Null Link

    Hi all, Ive created a new room template. First, I create a new workset and save it inside com.sap.ip.collaboration -> worksets All the iviews and pages of that workset are inside com.sap.ip.collaboration -> TemplateAndPartContent -> Generic After tha

  • How to install ubuntu on z 580

    dear anyone,                        hey i have purchased a lenovo z 580 ,and i want to install ubuntu on it along with the win7 home basic that came with the laptop ,when iam trying to install it is not showing the win 7 .... that it genrally shows w

  • TNT4882 and microcontroller

    Does anybody have informations on programming TNT4882 in microcontroller environnement. The application note concerning TNT4882 and 8051 is not very helpful for me. Thanks in advance