$ character in .CLASS files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aleplgr
    New Member
    • Aug 2007
    • 19

    #1

    $ character in .CLASS files

    Hi! I need to start to work in a medium-size application (500 classes) that some students have been developing for up to 2 years, the first thing I found is that for each .java file there are many (up to 30) .CLASS with the same name but with a $ and a sequencial number before the extension. For example:

    DlgOpcTFreq.jav a
    DlgOpcTFreq.cla ss
    DlgOpcTFreq$1.c lass
    DlgOpcTFreq$2.c lass
    DlgOpcTFreq$3.c lass
    DlgOpcTFreq$4.c lass
    .......
    DlgOpcTFreq$24. class
    DlgOpcTFreq$25. class

    I thought they were temporal files and deleted all of the ...$ files, keeping only the .java and the .class
    but now I can't run the program and compile nothing..

    And I was asked to delete (or find out what to do) with all those $ files...
    Those classes are in some way different than the others, but as I saw they can't be deleted, can they?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by aleplgr
    Hi! I need to start to work in a medium-size application (500 classes) that some students have been developing for up to 2 years, the first thing I found is that for each .java file there are many (up to 30) .CLASS with the same name but with a $ and a sequencial number before the extension. For example:

    DlgOpcTFreq.jav a
    DlgOpcTFreq.cla ss
    DlgOpcTFreq$1.c lass
    DlgOpcTFreq$2.c lass
    DlgOpcTFreq$3.c lass
    DlgOpcTFreq$4.c lass
    .......
    DlgOpcTFreq$24. class
    DlgOpcTFreq$25. class

    I thought they were temporal files and deleted all of the ...$ files, keeping only the .java and the .class
    but now I can't run the program and compile nothing..

    And I was asked to delete (or find out what to do) with all those $ files...
    Those classes are in some way different than the others, but as I saw they can't be deleted, can they?
    Those are the files that contain the compiled anonymous classes. e.g:

    [code=java]
    public class MyButton extends JButton {
    public MyButton() {
    // this generates a MyButton$1.clas s file:
    this.add(new ActionListener( ) {
    public void actionPerformed (ActionEvent ae) { ... }
    });
    }
    }
    [/code]

    kind regards,

    Jos

    Comment

    • aleplgr
      New Member
      • Aug 2007
      • 19

      #3
      THANKS.
      Alright so I'll never ever delete any of those, unless I wanted to re-implement them..

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by aleplgr
        THANKS.
        Alright so I'll never ever delete any of those, unless I wanted to re-implement them..
        You can only generate (compile) those $1, $2 ... files if you have the sources
        of the surroundig class. The compiler plays a few tricks on us because the jvm
        doesn't know about anonymous classes and the compiler synthesizes top level
        classes for us just like any other class and names them $1, $2 ... appended to
        the name of the outer classes.

        kind regards,

        Jos

        Comment

        Working...