JDK-4023606 : AppletViewer generates java.lang.UnknownError when loading inner class.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1
  • Priority: P2
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1996-12-29
  • Updated: 1997-01-10
  • Resolved: 1997-01-10
Description
The AppletViewer (in /usr/local/java/latest/bin) fails to load the
LoadInnerClassBug applet below, which contains an anonymous inner
class.  I got the following error message from AppletViewer

    [56]: /usr/local/java/latest/bin/appletviewer LoadInnerClassBug.html
    java.lang.UnknownError: LoadInnerClassBug$1
	    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java)
	    at LoadInnerClassBug.init(LoadInnerClassBug.java:14)
	    at sun.applet.AppletPanel.run(AppletPanel.java:273)
	    at java.lang.Thread.run(Thread.java)


The applet's source file was compiled as:

    /usr/local/java/latest/bin/javac LoadInnerClassBug.java

    Compilation finished at Sun Dec 29 14:38:27


Applet's source and html file:

---------------- LoadInnerClassBug.java ----------------

import java.awt.*;
import java.awt.event.*;

public class LoadInnerClassBug extends java.applet.Applet {

    static final String SHOW_NEW_FRAME = "Show New Frame";

    int frameCounter;
    Button showButton = new Button(SHOW_NEW_FRAME);

    /** Builds the applet's interface. */
    public void init() {
	add(showButton);
	showButton.addActionListener(new ActionListener() {
	    public void actionPerformed(ActionEvent e) {
		/* Use conditional to work around inlining bug (#4023605) */
		if (SHOW_NEW_FRAME.equals(showButton.getLabel())) {
		    doSomething();
		}
	    }
	});
    }

    void doSomething() {
	++frameCounter;
    }

}

---------------- LoadInnerClassBug.html ----------------

<html>
<head>
<title>LoadInnerClassBug</title>
</head>

<body>

<strong>LoadInnerClassBug</strong> -- here's what it does ...
<br>

<hr>
<applet code="LoadInnerClassBug.class" width=480 height=240>
</applet>
<hr>

<a href="LoadInnerClassBug.java">The source.</a>

</body>
</html>

Comments
EVALUATION [saraiya 1/10/97] Can't reproduce with JDK1.1b3.2, probably due to numerous compiler fixes made by jrose over the break. I slightly modified the code so that doSomething prints to stdout and got the following output: worthy% /usr/local/java/latest/bin/appletviewer classes/LoadInnerClassBug.html hit: 1 hit: 2 hit: 3 hit: 4 hit: 5 hit: 6 hit: 7 worthy% appletviewer LoadInnerClassBug.html hit: 1 hit: 2 hit: 3 hit: 4 hit: 5 hit: 6 hit: 7 hit: 8 hit: 9 hit: 10 hit: 11
11-06-2004