Results 1 to 16 of 16
  1. #1
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    441
    Rep Power
    6

    Default Format of class file

    Does any one know what is the format of Class file ?

    Can any one tell me what are the first four bytes of class file?
    Last edited by makpandian; 06-24-2009 at 09:15 PM. Reason: Solved
    Mak
    (Living @ Virtual World)

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    11001010
    11111110
    10111010
    10111110

  4. #4
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    its a byte code in the form of zeros and ones

  5. #5
    guru_boy is offline Member
    Join Date
    Apr 2009
    Posts
    7
    Rep Power
    0

    Default

    .bin,
    javac compiles the code into pure binary format, but dont expect notepad will show you that format of 0,1.

    instead you will need a decompiler.

    and that's why we cant read the tabular format data (tables) we create
    by using filehandling in java

  6. #6
    guru_boy is offline Member
    Join Date
    Apr 2009
    Posts
    7
    Rep Power
    0

    Default

    @ makpandian

    it is very basic thing you will find in introductory text of any book of java

  7. #7
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    441
    Rep Power
    6

    Default

    Hello
    I know that Class file is stores as 0,1

    In JPG file it contains some header and data block .Like this Class file also has some standard format.But this format is only can be understood by JRE.

    That ' s why i ask that?

    If we know that structure we can create class file with out writing progam.
    Mak
    (Living @ Virtual World)

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    I gave you the first four bytes, but there is a hell of a lot more to it than that.

    VM Spec The class File Format

  9. #9
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    441
    Rep Power
    6

    Default

    Thanks masijade.I got it.
    I think you are the only man who understood what i tried to tell here.
    Mak
    (Living @ Virtual World)

  10. #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Of course, if this is a homework/quiz question, I can guarantee that the instructor will not like that answer. I am quite sure (s)he will be looking for something else. Although the answer given is correct.

  11. #11
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    441
    Rep Power
    6

    Default

    Yes Sure,This ques was asked in my interview.
    I told that it contains some binary data.But he wanted some info regarding that like as you mentioned here
    Mak
    (Living @ Virtual World)

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Quote Originally Posted by makpandian View Post
    Yes Sure,This ques was asked in my interview.
    I told that it contains some binary data.But he wanted some info regarding that like as you mentioned here
    Blimey. What a ridiculous question, unless the job involved writing a Java compiler.

  13. #13
    einarb is offline Member
    Join Date
    Mar 2009
    Posts
    22
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Blimey. What a ridiculous question, unless the job involved writing a Java compiler.
    Not really.

    Ever tried searching a ton of large jars for annotations? you don't want the reflection api for that, as it's to slow and you will probably run out of memory from loading all the classes. Parsing the bytecode is better.

    There are probably quite a few other uses too other than writing compilers, but you probably won't see them until someone comes up with some ubscure requirements for your application.

    And it's always good to have at least some idea about what happens under the hood.

    Depends on the job I guess.

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Quote Originally Posted by einarb View Post
    Not really.

    Ever tried searching a ton of large jars for annotations? you don't want the reflection api for that, as it's to slow and you will probably run out of memory from loading all the classes. Parsing the bytecode is better.

    There are probably quite a few other uses too other than writing compilers, but you probably won't see them until someone comes up with some ubscure requirements for your application.

    And it's always good to have at least some idea about what happens under the hood.

    Depends on the job I guess.
    When, in all honesty, has that been a necessity? I have never worked on a project (and I've been doing this a while) where there has been a need to parse the byte code.

    Yes, understanding what goes on under the hood is useful, but to extend that to a (let's be honest) fairly deep understanding of the byte format strikes me more as an interviewer trying to be all clever-clever. In which case I'd be dubious about the code they'd produced...

  15. #15
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    You seem to be missing the point of job interviews - to stretch and challenge the candidate.

    There are many companies that use custom Java compilers and runtime environments. Plus Java bytecode is a popular intermediate language used in compiler study and design for many different languages.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Quote Originally Posted by OrangeDog View Post
    You seem to be missing the point of job interviews - to stretch and challenge the candidate.
    Well, no. They're to find out if you can do the role for which you've applied.

    Maybe it's a contractor thing, and we don't get asked this stuff (except by the aforementioned someone trying to be clever-clever)...

    Quote Originally Posted by OrangeDog View Post
    There are many companies that use custom Java compilers and runtime environments. Plus Java bytecode is a popular intermediate language used in compiler study and design for many different languages.
    Yes, I'm sure there are. Which is why I asked whether it was a job to do with compilers.

    However, if it was your bog-standard Java programmer/developer/whatever role then it is a rather silly question, and isn't actually going to filter out anyone who can't do the job (knowing the minutiae of the compiler is no guarantee of being able to code sensibly) and will probably filter out many who can.

Similar Threads

  1. PNG file format decoder in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 08:51 PM
  2. Replies: 0
    Last Post: 05-13-2008, 06:16 AM
  3. Replies: 1
    Last Post: 04-09-2008, 02:15 AM
  4. Convertin a .DAT file into readable format
    By janakiram.attuluri in forum Advanced Java
    Replies: 1
    Last Post: 12-07-2007, 10:00 PM
  5. Date format display in CSV file after exporting
    By latha in forum Advanced Java
    Replies: 0
    Last Post: 08-03-2007, 08:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •