Relates :
|
FULL PRODUCT VERSION : java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode) ADDITIONAL OS VERSION INFORMATION : TCC 16.00.40 x64 Windows 7 [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : AppletContext.getApplets will return only 1 applet, the caller, if there are 12+ instances of the Applet on a page. If there are less than 12 instances, it will give you all the instances. REGRESSION. Last worked in version 6u45 ADDITIONAL REGRESSION INFORMATION: A similar bug was fixed in JDK 1.3. I think this bug appeared somewhere since JDK 1.7.0 but did not reasearch it until today. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the provided MultiInstance Applet in a Firefox, Opera or IE browser. Click any of the buttons. It should give a report on the console of which other instances it can see. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Each instance should be able to see all the others. ACTUAL - If you have 11 instances on the page, it works as expected. You see all the other applets. If you have 12 instance of the page, each instance can see no other instances, just itself. However, with Chrome, with 12 it works. ERROR MESSAGES/STACK TRACES THAT OCCUR : I note that when it fails, there are also multiple consoles. I suspect the problem is related. I hit that little Green G, hoping it would let me upload the file. Instead, it erased my whole bug report. Growl! REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- /* * [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; // with 12 or more instances FireFox, Opera and IE fail. Applets cannot see the other Applets. // Chrome works with 12 instances. // 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="50" 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="50" 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. } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : This is a bloody nuisance because this code used to work. I have many web pages with an applet per price that automatically convert to the desired currency. There are other websites using this same program. The only pages that work have fewer than 12 prices on them.