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?
Printable View
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?
11001010
11111110
10111010
10111110
its a byte code in the form of zeros and ones
.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
@ makpandian
it is very basic thing you will find in introductory text of any book of java
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.
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
Thanks masijade.I got it.
I think you are the only man who understood what i tried to tell here.
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.
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
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...
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.
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)...
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.