Results 1 to 5 of 5
  1. #1
    drone13 is offline Member
    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    Lightbulb How would I read a .class file?

    Well I'm playing with metamorphism in Java because I am weird. I ran into the problem that every time I successfully meta-morph(make it rewrite itself) my source I have to recompile and it doesn't keep running because there's nothing to tell it to run again unless I summon a batch file or something.

    Then I realized, hey what if I could just directly edit a .class file? Also I did think it through so it shouldn't die (you can't perform invasive surgery on yourself). The program will copy itself modify the copy then destroy the original.

    So the point is... How do .class files work and where can I read up on it? And don't tell me to do this in some other language because I don't feel like to, that'd be boring.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You read up on .class files in the first chapters of the VM specification (freely available).

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

    Default

    Google BCEL.

    If you want to "read up on it", then read the JLS/JVM specs (you can find them at Sun, of course).

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

    Default

    Of course, you can always use the "Compiler" classes, then load it with ClassLoader (defineClass or loadClass or something like that) then call the "proper" method with reflection, just keep an eye on the stack.

  5. #5
    drone13 is offline Member
    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    Default

    There's a compiler class? Dang! There's a class for everything... If only I know about them... thanks +1 rep ^_^

Similar Threads

  1. Replies: 2
    Last Post: 05-11-2009, 11:07 AM
  2. Replies: 0
    Last Post: 02-11-2009, 10:53 AM
  3. Replies: 5
    Last Post: 02-05-2009, 11:28 AM
  4. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 10:13 AM
  5. Using Scanner class to read int value
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 10:34 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
  •