File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does byte[] get compiled in the class file?

 
ying lam
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If I have a method which has a byte[] as its variable,

public void f1() {
byte[] matchBytes = {0x50, 0x4e, 0x47};
...
}

like this, how does that compile into a class file?
When I open the compiled class file, and search for '0x50' '0x4e' '0x47', nothing is found.

And what if I have a class which has static constants attribute of byte[] matchBytes = {0x50, 0x4e, 0x47}; how does that compile into a class file?

Thank you.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's rather unsettling, actually. Array initializers aren't compiled into a block of data that can be copied directly into an array; they're compiled into a stream of executable code that sets the elements of the array one at a time!



You can disassemble classes like this using the "javap" tool: "javap -c Foo" shows you the bytecode for class Foo.
 
ying lam
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic