Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28056 > unrolled thread

AppletContext.getApplets

Started byRoedy Green <see_website@mindprod.com.invalid>
First post2014-04-13 00:17 -0700
Last post2014-04-16 06:45 +0800
Articles 14 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  AppletContext.getApplets Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 00:17 -0700
    Re: AppletContext.getApplets Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 01:09 -0700
    Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 03:52 -0700
      Re: AppletContext.getApplets bug Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2014-04-13 21:47 +0800
        Re: AppletContext.getApplets bug Jeff Higgins <jeff@invalid.invalid> - 2014-04-13 13:03 -0400
          Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 17:17 -0700
            Re: AppletContext.getApplets bug Jeff Higgins <jeff@invalid.invalid> - 2014-04-13 21:09 -0400
              Re: AppletContext.getApplets bug Jeff Higgins <jeff@invalid.invalid> - 2014-04-13 21:17 -0400
                Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-14 01:43 -0700
        Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 16:58 -0700
        Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 17:08 -0700
        Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-14 14:45 -0700
      Re: AppletContext.getApplets bug Roedy Green <see_website@mindprod.com.invalid> - 2014-04-13 19:13 -0700
        The End is Nigh Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2014-04-16 06:45 +0800

#28056 — AppletContext.getApplets

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 00:17 -0700
SubjectAppletContext.getApplets
Message-ID<h7ekk9pkobomg2vfi9kik12mpthvgsj5pa@4ax.com>
I wrote an Applet many moons ago that uses AppletContext.getApplets to
communicate with other instances of itself on the same page.  

It used to work fine. But now, if there more about 3 instances, it
seems to be able to communicate only with some of the other instances.
I am in the process of debugging this.

I suspect that in the old days all applets on a page were visible, but
now there are several independent pools of applets where the number of
instances gets large, so no longer can any one applet see everything.

Has anyone heard of any thing like this, or anything else that might
have changed that interferes with inter-applet communication?
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [next] | [standalone]


#28058

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 01:09 -0700
Message-ID<eahkk91q521tk2v5jbos3v4hb4tqsktju7@4ax.com>
In reply to#28056
On Sun, 13 Apr 2014 00:17:08 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>It used to work fine. But now, if there more about 3 instances, it
>seems to be able to communicate only with some of the other instances.
>I am in the process of debugging this.

I will have to write an SSCCE to demonstrate the bug, but from work
debugging CurrCon, it looks like and old bug in JDK 1.3 has
resurfaced.

AppletContext.getApplets returns just yourself if there are large
number of instances, where "large" has yet to be determined. 
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28059 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 03:52 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<6kqkk91s6fjg449puqci6mf68i0v8js6dr@4ax.com>
In reply to#28056
On Sun, 13 Apr 2014 00:17:08 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :


>I suspect that in the old days all applets on a page were visible, but
>now there are several independent pools of applets where the number of
>instances gets large, so no longer can any one applet see everything.

I have written an SSCCE and discovered that getApplets fails when
there are 12 or more instances on a page, at least in the Firefox
browser on Windows 7 64 bit.

Here is the proof:

/*
 * [MultiInstance]
 *
 * Summary: Demonstrate AppletContext.getApplets bug which fails for
more than 11 instances
 *
 * Copyright: (c) 2014 Roedy Green, Canadian Mind Products,
http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any
purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.7+
 *
 * Created with: JetBrains IntelliJ IDEA IDE
http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2001-03-08 initial
*/
package com.mindprod.example;

import javax.swing.JApplet;
import javax.swing.JButton;
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;

import static java.lang.System.out;

// simple jar build: jar -cvfm multi.jar manifest.mf
\com\mindprod\example\MultiInstance*.class
// manifest.mf looks like this:
//        Manifest-Version: 1.0
//        Application-Name: MultiInstance
//        Permissions: sandbox
//        Created-By: 1.8.0 (Oracle Corporation)
//        Main-Class: com.mindprod.example.MultiInstance

// run with multi.html
//that looks like this:
//        <!DOCTYPE HTML>
//        <html lang="en-CA">
//        <head>
//        <meta charset="utf-8">
//        </head>
//        <body>
//        <p>Click each applet to see which others it can see, listed
on the console.</p>
//
//        <object  type="application/x-java-applet" data="multi.jar"
width="40" height="20">
//        <param name="code"
value="com.mindprod.example.MultiInstance">
//        <param name="archive" value="multi.jar">
//        <param name="instance" value="1">     <!-- unique instance
identifier -->
//        Applet failed to run.
//        </object>
//
//        <object  type="application/x-java-applet" data="multi.jar"
width="40" height="20">
//        <param name="code"
value="com.mindprod.example.MultiInstance">
//        <param name="archive" value="multi.jar">
//        <param name="instance" value="2">
//        Applet failed to run.
//        </object>
//        ...      11 instances will work, 12 will fail.
//        </body>
//        </html>


/**
 * Demonstrate AppletContext.getApplets bug which fails for more than
11 instances
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2014-04-12 initial version
 * @since 2014-04-12
 */
public final class MultiInstance extends JApplet
    {
    // ------------------------------ CONSTANTS
------------------------------

    /**
     * which instance on the page are we, unique string
     */
    private String instance = "unknown";

    // -------------------------- PUBLIC INSTANCE  METHODS
--------------------------

    /**
     * constructor
     */
    public MultiInstance()
        {
        }

    /**
     * dump out who can see what
     */
    public void dump()
        {

        // dump out what getApplets provides
        final AppletContext ac = this.getAppletContext();

        // all Applets on page, possibly including us, including
non-MultiInstance
        final Enumeration<Applet> otherApplets = ac.getApplets();
        if ( otherApplets == null || !otherApplets.hasMoreElements() )
            {
            out.println( "instance " + instance + " unable to see any
other applets" );
            }
        else
            {
            while ( otherApplets.hasMoreElements() )
                {
                Applet other = otherApplets.nextElement();
                if ( other instanceof MultiInstance )
                    {
                    out.println( instance + " can see: instance " + (
( MultiInstance ) other ).getInstance() );
                    }
                else
                    {
                    out.println( instance + " can see: " +
other.getAppletInfo() );
                    }
                }
            }
        }

    public void init()
        {
        instance = getParameter( "instance" );

        JButton t = new JButton( instance );
        t.setBackground( Color.orange );
        this.add( t );
        t.addActionListener( new ActionListener()
        {
        /**
         * Invoked when user clicks button
         */
        public void actionPerformed( ActionEvent e )
            {
            dump();
            }
        } );
        this.validate();
        this.setVisible( true );
        }// end init

    // -------------------------- OTHER METHODS
--------------------------

    /**
     * which instance on the page are
     *
     * @return unique instance string
     */
    String getInstance()
        {
        return instance;
        }
    // has no main method.
    }

-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28061 — Re: AppletContext.getApplets bug

FromRichard Maher <maher_rjSPAMLESS@hotmail.com>
Date2014-04-13 21:47 +0800
SubjectRe: AppletContext.getApplets bug
Message-ID<lie4hk$806$1@speranza.aioe.org>
In reply to#28059
On 4/13/2014 6:52 PM, Roedy Green wrote:
> On Sun, 13 Apr 2014 00:17:08 -0700, Roedy Green
> <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
> someone who said :
>
>
>> I suspect that in the old days all applets on a page were visible, but
>> now there are several independent pools of applets where the number of
>> instances gets large, so no longer can any one applet see everything.
>
> I have written an SSCCE and discovered that getApplets fails when
> there are 12 or more instances on a page, at least in the Firefox
> browser on Windows 7 64 bit.
>

Anything in the FF Web Console or Java console? What was the error 
again? Do other browsers break at 13 as well?

if you run with separate classloaders or JMS does the problem go away? 
(Clearly inter-Applet communication will get harder :-)

<PARAM name="separate_jvm" value="true">

<PARAM name="classloader_cache" value="false">

Cheers Richard "I hate Eric Costlow and can't understand how anyone with 
such a Java anemic CV can have his job!" Maher

[toc] | [prev] | [next] | [standalone]


#28067 — Re: AppletContext.getApplets bug

FromJeff Higgins <jeff@invalid.invalid>
Date2014-04-13 13:03 -0400
SubjectRe: AppletContext.getApplets bug
Message-ID<lieg85$uep$1@dont-email.me>
In reply to#28061
On 04/13/2014 09:47 AM, Richard Maher wrote:

> What was the error again?
+1

[toc] | [prev] | [next] | [standalone]


#28076 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 17:17 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<jo9mk995ond8vvg6sdm2nn9j9gks5egbh3@4ax.com>
In reply to#28067
On Sun, 13 Apr 2014 13:03:49 -0400, Jeff Higgins
<jeff@invalid.invalid> wrote, quoted or indirectly quoted someone who
said :

>
>> What was the error again?
>+1

AppletContex.getApplets returns an enumeration of all the Applets
running on the page, including yourself.  

It works correctly when there are 1 to 11 instances of the Applet.

When you have 12+, the enumeration contains only 1 element, namely
yourself.  You can't see any of the other Applets.

Firefox, Opera, IE all behave this way.  Chrome works for n=12. I have
not done experiments for larger numbers.

I think what is happening is 12 or above, Firefox gives each Applet
not only a separate thread, but a separate JVM. Another symptom is the
appearance of multiple consoles at 12+

Either a browser should put all Applets of the same class in the same
JVM, or give you a way to force that.

Oracle, if they do anything, may just add a warning the documentation
for getApplets that it does not work for values of n+, where n is
determined by experiment.

Bugs like this give much more grief that my own bugs.  I expect the
system stuff to work as advertised, and keep looking for something
wrong it my own code, and only as a last resort start exploring the
possibility Oracle erred.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28080 — Re: AppletContext.getApplets bug

FromJeff Higgins <jeff@invalid.invalid>
Date2014-04-13 21:09 -0400
SubjectRe: AppletContext.getApplets bug
Message-ID<lifcme$3gh$1@dont-email.me>
In reply to#28076
On 04/13/2014 08:17 PM, Roedy Green wrote:
>>> What was the error again?

[toc] | [prev] | [next] | [standalone]


#28081 — Re: AppletContext.getApplets bug

FromJeff Higgins <jeff@invalid.invalid>
Date2014-04-13 21:17 -0400
SubjectRe: AppletContext.getApplets bug
Message-ID<lifd66$7kp$1@dont-email.me>
In reply to#28080
On 04/13/2014 09:09 PM, Jeff Higgins wrote:
> On 04/13/2014 08:17 PM, Roedy Green wrote:
>>>> What was the error again?
>
Oops. So there is no error.
Only behavior you did not expect.

[toc] | [prev] | [next] | [standalone]


#28083 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-14 01:43 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<mg7nk9le9ebduio5p0i6d04gu12pjquv87@4ax.com>
In reply to#28081
On Sun, 13 Apr 2014 21:17:40 -0400, Jeff Higgins
<jeff@invalid.invalid> wrote, quoted or indirectly quoted someone who
said :

>Oops. So there is no error.
>Only behavior you did not expect.

jdk1.8.0/docs/api/java/applet/AppletContext.html#getApplets--

Enumeration<Applet> getApplets()

Finds all the applets in the document represented by this applet
context.
Returns:
an enumeration of all applets in the document represented by this
applet context.

It does not return ALL the Applets, only some of them, and sometimes
NONE of them but yourself. I consider that a bug.  Now a lawyer would
argue about the sleazoid "context" wording to excuse the behaviour.
The docs should at least warn you that it only works up to 11
instances. Oracle instead screws you around so they don't have to
admit a problem.

You test with 2 or 3 instances.  It works, so you assume it will work
for more.  IT DOES NOT. And the buggers refuse to warn you.  I have
wasted so much time on this that coud have been saved by adding one
sentence to the docs.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28074 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 16:58 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<l39mk9tnf4p384gms9c44s472846of2eeh@4ax.com>
In reply to#28061
On Sun, 13 Apr 2014 21:47:33 +0800, Richard Maher
<maher_rjSPAMLESS@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>
>Anything in the FF Web Console or Java console? What was the error 
>again? Do other browsers break at 13 as well?

FireFox, Opera and IE fail at 12+
Chrome works at 12.  I have have not yet found out it it too has a
limit.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28075 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 17:08 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<o69mk9temsml1rb0samh5ivgr15ugr8afi@4ax.com>
In reply to#28061
On Sun, 13 Apr 2014 21:47:33 +0800, Richard Maher
<maher_rjSPAMLESS@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

><PARAM name="separate_jvm" value="true">
>
><PARAM name="classloader_cache" value="false">

Somebody goofed at using the same syntax for system and user
parameters.  It makes every new system parm a reserved word.

If you used separate_jvm I would expect getApplets not to work. I
think that is what is happening, because you suddenly start getting
large numbers of consoles when you hit the 12 limit. It is not one JVM
per applet and it is not two JVMs either, the way you might expect
when you hit 12.

You have a common static region for communication if all Applets are
in the same JVM.

I think I will try:
<PARAM name="separate_jvm" value="false">
to see if it forces a common JVM. The applets are quite tiny and have
little overhead.

I will have to read up on classloader_cache to see how it fits in.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28084 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-14 14:45 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<hnlok9hu13vmn8qb1pf9dulk19dmdvmeg3@4ax.com>
In reply to#28061
On Sun, 13 Apr 2014 21:47:33 +0800, Richard Maher
<maher_rjSPAMLESS@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

><PARAM name="separate_jvm" value="true">

with 12+ instances FireFox, Opera and IE fail. Applets cannot see the
other Applets.
Chrome fails with 13+ instances.
With <param  name="separate_jvm" value="false"> Chrome, ironically
fails on 12+ instances.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28082 — Re: AppletContext.getApplets bug

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-13 19:13 -0700
SubjectRe: AppletContext.getApplets bug
Message-ID<20hmk9p2v0d26v069a6jpttr9vdpa5h37b@4ax.com>
In reply to#28059
On Sun, 13 Apr 2014 03:52:55 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>I have written an SSCCE and discovered that getApplets fails when
>there are 12 or more instances on a page, at least in the Firefox
>browser on Windows 7 64 bit.

For Firefox, Opera and IE it fails on 12+ instances.
For Chrome it fails on 13+ instances
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [next] | [standalone]


#28095 — The End is Nigh

FromRichard Maher <maher_rjSPAMLESS@hotmail.com>
Date2014-04-16 06:45 +0800
SubjectThe End is Nigh
Message-ID<likcr2$1cf$1@speranza.aioe.org>
In reply to#28082
On 4/14/2014 10:13 AM, Roedy Green wrote:
> On Sun, 13 Apr 2014 03:52:55 -0700, Roedy Green
> <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
> someone who said :
>
>> I have written an SSCCE and discovered that getApplets fails when
>> there are 12 or more instances on a page, at least in the Firefox
>> browser on Windows 7 64 bit.
>
> For Firefox, Opera and IE it fails on 12+ instances.
> For Chrome it fails on 13+ instances
>

You should be more worried about Chrome not working with NPAPI next 
month (should've been this month but received a stay of execution).

Google has taken Larry out in the street and bitch-slapped him in front 
of everyone and he's just taking it :-(

This is a deliberate calculated malicious attack on Java's longevity and 
worst of all it is clearly gratuitous from any technical viewpoint.

But with demonstrable dickheads calling the shots at Oracle Applet 
engineering and this newsgroup full of numpties getting their jollies 
over lambdas what do you expect?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web