PDA

Click to See Complete Forum and Search --> : Compiling problem???


Virtual24
Apr 28th, 2003, 10:37 PM
When I compile any Java program wit 'javac' its splits the main class file into different parts ( ex. MyClass.class, MyClass$1.class, and so on ) Then when I load them on the web ( they are for an applet ) the webshell makes the '$' a '_' because '$'s aren't aloud!! My javac didn't used to do that. Why is it? Any ideas????

Dillinger4
Apr 29th, 2003, 12:48 AM
Not sure about the web part but the $'s are produced by the compiler to mark the classes or interfaces within the inheritance heirachy. For instance the following code should produce the following class files when compiled.

TopLevelClass$NestedTopLevelClass$NestedTopLevelClass1.class
TopLevelClass$NestedTopLevelInterface1.class
TopLevelClass$NestedTopLevelClass.class
TopLevelClass.class

public class TopLevelClass {
static NestedTopLevelClass{

interface NestedTopLevelInterface1{
}

static class NestedTopLevelClass1
implements NestedTopLevelInterface1{
}
}
}

CornedBee
Apr 29th, 2003, 10:47 AM
SomeClass$1.class is for the first anonymous nested class you declare, $2 for the second etc.
So

class MyClass
{
JButton button = new JButton();
public MyClass() {
button.addActionListener(new ActionListener() {
public void actionPeformed(ActionEvent e) {
}
} );
}
}

results in
MyClass.class
MyClass$1.class

Virtual24
Apr 29th, 2003, 08:37 PM
ahhh i see... cuz i was using:


addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
//...
}
} );