This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Java bug: Object tag and archive attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Java bug: Object tag and archive attribute" Watch "Java bug: Object tag and archive attribute" New topic
Author

Java bug: Object tag and archive attribute

Walter Gabrielsen Iii
Ranch Hand

Joined: Apr 09, 2011
Posts: 158
I think that I have found a bug in Java itself, not a browser bug, regarding the Object tag, the 'archive' attribute of the Object tag, and the archive attribute's interaction with Java's internal AppletClassLoader.


I think a little background detail is needed here. Java applets were first embeded into web pages with the APPLET tag and the "archive" attribute on the APPLET tag was a comma-separated list -- this part is important! The replacement for APPLET is supposed to be the Object tag which also has an "archive" attribute but this version of the "archive" attribute takes a space-separated list of values.


So, to the bug, I open the Java Console, trigger logging mode, set trace to level 5, and then open a page with an applet, embeded with the Object tag, using the attribute: (the full version is found below).

This is what appears in the Java Console using Object's version of the archive attribute:
Plugin2ClassLoader.addURL parent called for file:/C:/Desktop/applet/applet/myApplet.class archive1.jar archive2.jar

-- Java thinks it has a single file name: "myApplet.class archive1.jar archive2.jar"

-- Java should have seen three files and cached at least two (the jar files):
1 myApplet.class
2 archive1.jar
3 archive2.jar


Okay, so then, after that, I added a Param tag, formatted using a comma-separated list, just like the APPLET tag uses:

Java's new output:

Plugin2ClassLoader.addURL parent called for file:/C:/Desktop/applet/applet/archive1.jar
Plugin2ClassLoader.addURL parent called for file:/C:/Desktop/applet/applet/archive2.jar


Now it works. Java's applet class loader found the jar files and called them.

So, it appears, that Java's internal class loader is broken -- it only takes a comma-separated list for reading an archive attribute's value. This conflicts with Object's specification of the archive tag which is space-separated. Yet what happens is that Java can't read Object's archive attribute correctly if its longer than 1 item long because Java only reads comma-separated lists of archives.

Run using Java Plug-in 1.6.0_32, that's Java SE 1.6.0_32 release (the current latest version from http://www.java.com).

Just so you know, if you try to recreate this, this is how I sorted my File Locations:
C:\Desktop\applet -- where the html file using the Object tag is located.
C:\Desktop\applet\applet -- where the applet's *.class and .jar files are located.

The full object code (and this was intentionally made verbose for maximum use and browser support) (Note: the code is html 4.01 not xhtml, so remember to close the param tags with slash-bracket "/>" if you copy this code into an xhtml file):

Andrew Thompson
Ranch Hand

Joined: Aug 05, 2010
Posts: 77
    
    5
Walter Gabrielsen Iii wrote:..The replacement for APPLET is supposed to be the Object tag ..


Oracle currently supports the Deployment Toolkit Script.


Andrew Thompson
http://pscode.org/
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Yeah, don't use OBJECT or EMBED. The APPLET tag works fine in my experience, though, but it doesn't handle checking for a particular Java version being installed, and steering the user to download it if necessary.
Walter Gabrielsen Iii
Ranch Hand

Joined: Apr 09, 2011
Posts: 158
Yes using the Applet tag, or the script, does work. So does overloading Object with param values.

I just find it odd that Java can choke up over the difference between a space and a comma. It must be Java's rendering engine that chokes because I'm following its messages through the Java Console in multiple browsers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java bug: Object tag and archive attribute
 
Similar Threads
extra jar package problem
jar file
Basic Questions
Calling applet method in JAR file from Javascript
ClassNotFoundException while using Applet