I really wasn't kidding, what's up what this, no harm in trying it
yourself :
public class Ghost extends javax.swing.JFrame {
public static void main(String[] args) {
Ghost app=new Ghost();
app.setSize(400,300);
app.setVisible(true);
}
}
I ran it on WinXP home Java1.5.0_06.
Luke Webber - 09 Jul 2006 06:15 GMT
> I really wasn't kidding, what's up what this, no harm in trying it
> yourself :
[quoted text clipped - 8 lines]
>
> I ran it on WinXP home Java1.5.0_06.
Hey, you're right. Spooky! <g>
Luke
Andrew T. - 09 Jul 2006 08:22 GMT
> I really wasn't kidding,
Your initial post had me believing you were (and you had a
very strange sense of humor - not that that's a bad thing)
>...what's up what this, no harm in trying it
> yourself :
I prefer a self contained demo., which also tests the assertion
that the frame's title has something to do with it. That was
suggested in the Sun thread.
<sscce>
import java.awt.*;
import javax.swing.*;
class Ghost extends JFrame {
Ghost() {
setPreferredSize(new Dimension(200,200));
getContentPane().add( new JLabel("Boo!") );
pack();
}
}
class Spirit extends JFrame {
Spirit() {
setPreferredSize(new Dimension(200,200));
getContentPane().add( new JLabel("Drink!") );
pack();
}
}
class TestGhost {
public static void main(String[] args) {
Ghost ghost1 = new Ghost();
Ghost ghost2 = new Ghost();
ghost2.setTitle("Spirit");
ghost1.setVisible(true);
System.out.println( "ghost1: " + ghost1.getTitle() );
ghost2.setVisible(true);
System.out.println( "ghost2: " + ghost2.getTitle() );
Spirit ghost3 = new Spirit();
Spirit ghost4 = new Spirit();
ghost4.setTitle("Ghost");
ghost3.setVisible(true);
System.out.println( "ghost3: " + ghost3.getTitle() );
ghost4.setVisible(true);
System.out.println( "ghost4: " + ghost4.getTitle() );
JPanel p = new JPanel( new BorderLayout() );
JTextArea ta = new JTextArea();
ta.append(System.getProperty("java.version") + "\n");
ta.append(System.getProperty("os.name") + "\n") ;
ta.append( ghost1.isVisible() + " " ) ;
ta.append( ghost2.isVisible() + " " ) ;
ta.append( ghost3.isVisible() + " " ) ;
ta.append( ghost4.isVisible() + " " ) ;
JOptionPane.showMessageDialog( (Component)null, ta );
}
}
</sscce>
My results here are..
1.5.0-beta
Windows XP
true true true true
While only the two 'Spirit' class frames actually show.
Andrew T.
Andrew T. - 09 Jul 2006 08:46 GMT
> ..only the two 'Spirit' class frames actually show.
This problem also affects any class called 'Ghost'
which extends java.awt.Frame. The problem does
not seem to affect a Window.
Andrew T.
Andrew T. - 09 Jul 2006 09:23 GMT
If you further alter this source to extend Ghost..
> <sscce>
> import java.awt.*;
[quoted text clipped - 7 lines]
> }
> }
class GhostChild extends Ghost {
GhostChild() {
super();
}
}
.....
> class TestGhost {
> public static void main(String[] args) {
> Ghost ghost1 = new Ghost();
GhostChild ghost2 = new GhostChild();
...
GhostChild appears OK.
This problem seems very specific to sub-classes of
Frame/JFrame called 'Ghost', but not their children.
So far, we only have test results for Windows boxes
(AFAIU), I would be interested to hear any test results
for other OS's.
Andrew T.
> Did you run something like this ? default package ?
>
[quoted text clipped - 3 lines]
> }
> }
No, I had understood you to be talking about the name of the frame, not the
name of the class it is an instance of.
Trying it (with AWT frames), I see exactly what you are seeing ;-)
Interesting...
It seems only to happen on Windows -- at least, a quick test with a 1.4 JVM on
Linux did not show the effect.
I spent some time trying to find the source of the effect in the code -- in
fact I wasted most of yesterday :-( Couldn't find it.
The string "Ghost" does not appear in JVM.DLL (case-insensitive). It appears
as a "utf8" constant pool entry in only two classes in rt.jar, neither of which
is relevant (the name of the constant static integer field,
sun.awt.shell.Win32ShellFolder2.ATTRIB_GHOSTED, and the method name
java.net.authenticator.requestingHost()).
At the implementation level (in case anyone's interested), the call to
setVisible(true) ends up in the peer's native method
sun.awt.windows.WComponentPeer.pShow(). The JNI implementation just sends a
custom Windows message with value 0x8004 to the real Windows window. That
message is ignored if the AWT frame's class is named "Ghost", and acted on
otherwise. There is no conditional code in the place where the message is
received. I can show/hide the Window by using the normal Win32 APIs directly
but not by using them to send the custom message. I'm pretty sure that's
because the Windows windows has not been set up with a WindProc, whereas all
other Frames have one. I haven't been able to find any conditional code to
cause that effect, however, and having spent too long getting that far, I just
gave up.
The fact that it /is/ so well hidden, suggests that the Easter egg theory may
be correct. Surely legitimate code (even /bad/ legitimate code as suggested by
"PofN") wouldn't actually be hidden...
-- chris
Andrew T. - 11 Jul 2006 08:27 GMT
..
> > public class Ghost extends javax.swing.JFrame {
> > public static void main(String[] args) {
> > new Ghost().setVisible(true);
> > }
> > }
..
> Interesting...
>
> It seems only to happen on Windows -- at least, a quick test with a 1.4 JVM on
> Linux did not show the effect.
>
> I spent some time trying to find the source of the effect in the code --
(not resolved)
..
> The fact that it /is/ so well hidden, suggests that the Easter egg theory may
> be correct. Surely legitimate code (even /bad/ legitimate code as suggested by
> "PofN") wouldn't actually be hidden...
Now that it is established as a bug specific to Windows,
do you intend to lodge a bug-report, Paul?
I think it's important it be 'findable' in the bug database,
even if only as a warning* to other developers.
* Assuming Sun decides it is not worth fixing.
Andrew T.
Paul Hamaker - 11 Jul 2006 10:22 GMT
> Now that it is established as a bug specific to Windows,
> do you intend to lodge a bug-report, Paul?
Already did.
Andrew T. - 11 Jul 2006 10:36 GMT
> > Now that it is established as a bug specific to Windows,
> > do you intend to lodge a bug-report, Paul?
> Already did.
Where? I cannot see it amongst these results.
<http://bugs.sun.com/bugdatabase/search.do?process=1&category=&bugStatus=&subcate
gory=&type=&keyword=ghost>
Andrew T.
Paul Hamaker - 16 Jul 2006 08:37 GMT
Andrew T. schreef:
> Where? I cannot see it amongst these results.
My report has been assigned an internal review ID of 745063, which is
NOT visible on the Sun Developer Network (SDN).
Andrew Thompson - 16 Jul 2006 13:05 GMT
> Andrew T. schreef:
> > Where? I cannot see it amongst these results.
> My report has been assigned an internal review ID of 745063, which is
> NOT visible on the Sun Developer Network (SDN).
Maybe a bug mentioning the word 'ghost' suffers the
same fate as a Frame. ;-)
Andrew T.
Thomas Hawtin - 16 Jul 2006 20:03 GMT
> Maybe a bug mentioning the word 'ghost' suffers the
> same fate as a Frame. ;-)
I've got an "incident review" without a bug ID involving Swing 'Timer'
not firing that must be two and a half years old. Mind you, I have
changed e-mail address in that period.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/