Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Albireo » CTRL-C stack overflow
CTRL-C stack overflow [message #3404] Wed, 10 October 2007 17:35 Go to next message
Eclipse UserFriend
Originally posted by: canadianguy.gmail.com

I have noticed an interesting problem when you are using a Swing editor.
In a text field in the editor, hit CTRL-C. Open another editor. Watch the
stack overflow errors pile up.

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
at java.util.Collections.sort(Collections.java:159)
at
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
aversalPolicy.java:119)
at
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
salPolicy.java:434)
at
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
lPolicy.java:148)
at
javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
9)
at
javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
TraversalPolicy.java:115)
at
javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
usTraversalPolicy.java:133)
at
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
salPolicy.java:447)
...

I was able to fix this by moving the focus policy from the frame down to the
JApplet. I notice your article code says to 'consider' this in its
comments, is there any reason why you didn't do it?

-James

Modified code (inside addRootPaneContainer):
...
JApplet applet = new JApplet();

// In JRE 1.4, the JApplet makes itself a focus cycle root. This
// interferes with the focus handling installed on the parent frame,
so
// change it back to a non-root here.
// TODO: consider moving the focus policy from the Frame down to the
JApplet

EmbeddedChildFocusTraversalPolicy policy = new
EmbeddedChildFocusTraversalPolicy(awtHandler);
applet.setFocusTraversalPolicy(policy);
frame.add(applet);

return applet;
Re: CTRL-C stack overflow [message #3437 is a reply to message #3404] Wed, 10 October 2007 18:04 Go to previous messageGo to next message
Gordon Hirsch is currently offline Gordon HirschFriend
Messages: 100
Registered: July 2009
Senior Member
The choice of JApplet was made rather late, relative to the article's
release. I wanted to think it through before making the change. In
particular, if the AWT frame gets focus, will it always delegate to the
JApplet's focus policy?

If you are running in JDK 1.5+, I believe you could have also solved the
problem by calling setFocusTraversalPolicyProvider(false) on the
JApplet, leaving the focus traversal policy on the frame. This call is
now necessary to truly turn off the JApplet's own default focus
handling. This is a new API in 1.5. My testing was largely with JDK 1.4
at the time, so this call was not necessary and not available.

James Peltzer wrote:
> I have noticed an interesting problem when you are using a Swing editor.
> In a text field in the editor, hit CTRL-C. Open another editor. Watch the
> stack overflow errors pile up.
>
> Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
> at java.util.Arrays.mergeSort(Arrays.java:1270)
> at java.util.Arrays.sort(Arrays.java:1210)
> at java.util.Collections.sort(Collections.java:159)
> at
> javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
> aversalPolicy.java:119)
> at
> javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:434)
> at
> javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
> lPolicy.java:148)
> at
> javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
> 9)
> at
> javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
> TraversalPolicy.java:115)
> at
> javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
> usTraversalPolicy.java:133)
> at
> javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:447)
> ...
>
> I was able to fix this by moving the focus policy from the frame down to the
> JApplet. I notice your article code says to 'consider' this in its
> comments, is there any reason why you didn't do it?
>
> -James
>
> Modified code (inside addRootPaneContainer):
> ...
> JApplet applet = new JApplet();
>
> // In JRE 1.4, the JApplet makes itself a focus cycle root. This
> // interferes with the focus handling installed on the parent frame,
> so
> // change it back to a non-root here.
> // TODO: consider moving the focus policy from the Frame down to the
> JApplet
>
> EmbeddedChildFocusTraversalPolicy policy = new
> EmbeddedChildFocusTraversalPolicy(awtHandler);
> applet.setFocusTraversalPolicy(policy);
> frame.add(applet);
>
> return applet;
>
>
Re: CTRL-C stack overflow [message #6708 is a reply to message #3404] Wed, 02 April 2008 20:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: canadianguy.gmail.com

Hey all,
It's been a while. I am still using my modified version of the original
article code. I was wondering if anyone has experienced problems with
ctrl+x crashing the VM. It seems to be unrelated to the ctrl+c problem I
had before.

Anyone? Anyone?

-James


"James Peltzer" <canadianguy@gmail.com> wrote in message
news:fej2em$2oi$1@build.eclipse.org...
> I have noticed an interesting problem when you are using a Swing editor.
> In a text field in the editor, hit CTRL-C. Open another editor. Watch
the
> stack overflow errors pile up.
>
> Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
> at java.util.Arrays.mergeSort(Arrays.java:1270)
> at java.util.Arrays.sort(Arrays.java:1210)
> at java.util.Collections.sort(Collections.java:159)
> at
>
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
> aversalPolicy.java:119)
> at
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:434)
> at
>
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
> lPolicy.java:148)
> at
>
javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
> 9)
> at
>
javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
> TraversalPolicy.java:115)
> at
>
javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
> usTraversalPolicy.java:133)
> at
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:447)
> ...
>
> I was able to fix this by moving the focus policy from the frame down to
the
> JApplet. I notice your article code says to 'consider' this in its
> comments, is there any reason why you didn't do it?
>
> -James
>
> Modified code (inside addRootPaneContainer):
> ...
> JApplet applet = new JApplet();
>
> // In JRE 1.4, the JApplet makes itself a focus cycle root. This
> // interferes with the focus handling installed on the parent
frame,
> so
> // change it back to a non-root here.
> // TODO: consider moving the focus policy from the Frame down to
the
> JApplet
>
> EmbeddedChildFocusTraversalPolicy policy = new
> EmbeddedChildFocusTraversalPolicy(awtHandler);
> applet.setFocusTraversalPolicy(policy);
> frame.add(applet);
>
> return applet;
>
>
Re: CTRL-C stack overflow [message #6715 is a reply to message #6708] Thu, 03 April 2008 12:24 Go to previous message
Eclipse UserFriend
Originally posted by: canadianguy.gmail.com

Never mind. As it turns out, it was an ID-10-T error.

The original RCP application I built on top of had an accelerator set for
'ctrl+x' to shutdown the application. This was never removed and sat around
for a year before I noticed it.

Sorry to waste anyone's time.

-James

"James Peltzer" <canadianguy@gmail.com> wrote in message
news:ft0qlu$f2o$1@build.eclipse.org...
> Hey all,
> It's been a while. I am still using my modified version of the original
> article code. I was wondering if anyone has experienced problems with
> ctrl+x crashing the VM. It seems to be unrelated to the ctrl+c problem I
> had before.
>
> Anyone? Anyone?
>
> -James
>
>
> "James Peltzer" <canadianguy@gmail.com> wrote in message
> news:fej2em$2oi$1@build.eclipse.org...
> > I have noticed an interesting problem when you are using a Swing editor.
> > In a text field in the editor, hit CTRL-C. Open another editor. Watch
> the
> > stack overflow errors pile up.
> >
> > Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
> > at java.util.Arrays.mergeSort(Arrays.java:1270)
> > at java.util.Arrays.sort(Arrays.java:1210)
> > at java.util.Collections.sort(Collections.java:159)
> > at
> >
>
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
> > aversalPolicy.java:119)
> > at
> >
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> > salPolicy.java:434)
> > at
> >
>
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
> > lPolicy.java:148)
> > at
> >
>
javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
> > 9)
> > at
> >
>
javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
> > TraversalPolicy.java:115)
> > at
> >
>
javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
> > usTraversalPolicy.java:133)
> > at
> >
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> > salPolicy.java:447)
> > ...
> >
> > I was able to fix this by moving the focus policy from the frame down to
> the
> > JApplet. I notice your article code says to 'consider' this in its
> > comments, is there any reason why you didn't do it?
> >
> > -James
> >
> > Modified code (inside addRootPaneContainer):
> > ...
> > JApplet applet = new JApplet();
> >
> > // In JRE 1.4, the JApplet makes itself a focus cycle root. This
> > // interferes with the focus handling installed on the parent
> frame,
> > so
> > // change it back to a non-root here.
> > // TODO: consider moving the focus policy from the Frame down to
> the
> > JApplet
> >
> > EmbeddedChildFocusTraversalPolicy policy = new
> > EmbeddedChildFocusTraversalPolicy(awtHandler);
> > applet.setFocusTraversalPolicy(policy);
> > frame.add(applet);
> >
> > return applet;
> >
> >
>
>
Re: CTRL-C stack overflow [message #572952 is a reply to message #3404] Wed, 10 October 2007 18:04 Go to previous message
Gordon Hirsch is currently offline Gordon HirschFriend
Messages: 100
Registered: July 2009
Senior Member
The choice of JApplet was made rather late, relative to the article's
release. I wanted to think it through before making the change. In
particular, if the AWT frame gets focus, will it always delegate to the
JApplet's focus policy?

If you are running in JDK 1.5+, I believe you could have also solved the
problem by calling setFocusTraversalPolicyProvider(false) on the
JApplet, leaving the focus traversal policy on the frame. This call is
now necessary to truly turn off the JApplet's own default focus
handling. This is a new API in 1.5. My testing was largely with JDK 1.4
at the time, so this call was not necessary and not available.

James Peltzer wrote:
> I have noticed an interesting problem when you are using a Swing editor.
> In a text field in the editor, hit CTRL-C. Open another editor. Watch the
> stack overflow errors pile up.
>
> Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
> at java.util.Arrays.mergeSort(Arrays.java:1270)
> at java.util.Arrays.sort(Arrays.java:1210)
> at java.util.Collections.sort(Collections.java:159)
> at
> javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
> aversalPolicy.java:119)
> at
> javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:434)
> at
> javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
> lPolicy.java:148)
> at
> javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
> 9)
> at
> javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
> TraversalPolicy.java:115)
> at
> javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
> usTraversalPolicy.java:133)
> at
> javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:447)
> ...
>
> I was able to fix this by moving the focus policy from the frame down to the
> JApplet. I notice your article code says to 'consider' this in its
> comments, is there any reason why you didn't do it?
>
> -James
>
> Modified code (inside addRootPaneContainer):
> ...
> JApplet applet = new JApplet();
>
> // In JRE 1.4, the JApplet makes itself a focus cycle root. This
> // interferes with the focus handling installed on the parent frame,
> so
> // change it back to a non-root here.
> // TODO: consider moving the focus policy from the Frame down to the
> JApplet
>
> EmbeddedChildFocusTraversalPolicy policy = new
> EmbeddedChildFocusTraversalPolicy(awtHandler);
> applet.setFocusTraversalPolicy(policy);
> frame.add(applet);
>
> return applet;
>
>
Re: CTRL-C stack overflow [message #573770 is a reply to message #3404] Wed, 02 April 2008 20:33 Go to previous message
James Peltzer is currently offline James PeltzerFriend
Messages: 43
Registered: July 2009
Member
Hey all,
It's been a while. I am still using my modified version of the original
article code. I was wondering if anyone has experienced problems with
ctrl+x crashing the VM. It seems to be unrelated to the ctrl+c problem I
had before.

Anyone? Anyone?

-James


"James Peltzer" <canadianguy@gmail.com> wrote in message
news:fej2em$2oi$1@build.eclipse.org...
> I have noticed an interesting problem when you are using a Swing editor.
> In a text field in the editor, hit CTRL-C. Open another editor. Watch
the
> stack overflow errors pile up.
>
> Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
> at java.util.Arrays.mergeSort(Arrays.java:1270)
> at java.util.Arrays.sort(Arrays.java:1210)
> at java.util.Collections.sort(Collections.java:159)
> at
>
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
> aversalPolicy.java:119)
> at
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:434)
> at
>
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
> lPolicy.java:148)
> at
>
javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
> 9)
> at
>
javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
> TraversalPolicy.java:115)
> at
>
javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
> usTraversalPolicy.java:133)
> at
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> salPolicy.java:447)
> ...
>
> I was able to fix this by moving the focus policy from the frame down to
the
> JApplet. I notice your article code says to 'consider' this in its
> comments, is there any reason why you didn't do it?
>
> -James
>
> Modified code (inside addRootPaneContainer):
> ...
> JApplet applet = new JApplet();
>
> // In JRE 1.4, the JApplet makes itself a focus cycle root. This
> // interferes with the focus handling installed on the parent
frame,
> so
> // change it back to a non-root here.
> // TODO: consider moving the focus policy from the Frame down to
the
> JApplet
>
> EmbeddedChildFocusTraversalPolicy policy = new
> EmbeddedChildFocusTraversalPolicy(awtHandler);
> applet.setFocusTraversalPolicy(policy);
> frame.add(applet);
>
> return applet;
>
>
Re: CTRL-C stack overflow [message #573829 is a reply to message #6708] Thu, 03 April 2008 12:24 Go to previous message
James Peltzer is currently offline James PeltzerFriend
Messages: 43
Registered: July 2009
Member
Never mind. As it turns out, it was an ID-10-T error.

The original RCP application I built on top of had an accelerator set for
'ctrl+x' to shutdown the application. This was never removed and sat around
for a year before I noticed it.

Sorry to waste anyone's time.

-James

"James Peltzer" <canadianguy@gmail.com> wrote in message
news:ft0qlu$f2o$1@build.eclipse.org...
> Hey all,
> It's been a while. I am still using my modified version of the original
> article code. I was wondering if anyone has experienced problems with
> ctrl+x crashing the VM. It seems to be unrelated to the ctrl+c problem I
> had before.
>
> Anyone? Anyone?
>
> -James
>
>
> "James Peltzer" <canadianguy@gmail.com> wrote in message
> news:fej2em$2oi$1@build.eclipse.org...
> > I have noticed an interesting problem when you are using a Swing editor.
> > In a text field in the editor, hit CTRL-C. Open another editor. Watch
> the
> > stack overflow errors pile up.
> >
> > Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
> > at java.util.Arrays.mergeSort(Arrays.java:1270)
> > at java.util.Arrays.sort(Arrays.java:1210)
> > at java.util.Collections.sort(Collections.java:159)
> > at
> >
>
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
> > aversalPolicy.java:119)
> > at
> >
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> > salPolicy.java:434)
> > at
> >
>
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
> > lPolicy.java:148)
> > at
> >
>
javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
> > 9)
> > at
> >
>
javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
> > TraversalPolicy.java:115)
> > at
> >
>
javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
> > usTraversalPolicy.java:133)
> > at
> >
>
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
> > salPolicy.java:447)
> > ...
> >
> > I was able to fix this by moving the focus policy from the frame down to
> the
> > JApplet. I notice your article code says to 'consider' this in its
> > comments, is there any reason why you didn't do it?
> >
> > -James
> >
> > Modified code (inside addRootPaneContainer):
> > ...
> > JApplet applet = new JApplet();
> >
> > // In JRE 1.4, the JApplet makes itself a focus cycle root. This
> > // interferes with the focus handling installed on the parent
> frame,
> > so
> > // change it back to a non-root here.
> > // TODO: consider moving the focus policy from the Frame down to
> the
> > JApplet
> >
> > EmbeddedChildFocusTraversalPolicy policy = new
> > EmbeddedChildFocusTraversalPolicy(awtHandler);
> > applet.setFocusTraversalPolicy(policy);
> > frame.add(applet);
> >
> > return applet;
> >
> >
>
>
Previous Topic:EclipseCon 2008
Next Topic:Albireo alpha available
Goto Forum:
  


Current Time: Thu Apr 18 02:40:29 GMT 2024

Powered by FUDForum. Page generated in 0.02489 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top