Java Reflection Code Applet

bigoh5

n00b
Joined
Mar 19, 2009
Messages
12
Hi all,

I ran across an interesting problem:

Write an applet that outputs its own source code in a green box. Do not use reflection to access the applet's code. Anyone have any insight into a problem like this?
 
Reflection isnt going to get you access to the code anyway.

Theres 2 ways i can see to do it, easy and very hard.
Easy: include the source code in the jar along with the class file. Then you just load and display it.

Very Difficult: Decompile the byte code, and display that. Not going to be the same as the source, but should be close enough. You are going to lose the comments and formatting.
Well, i guess its very hard if you write the decompiler yourself. People have done it before, so i suppose you could use their code to do it.
 
...
Theres 2 ways i can see to do it, easy and very hard.
Easy: include the source code in the jar along with the class file. Then you just load and display it.
...

As ambientZ said, this is probably the easist way to do it. You can stick the sources in the jar and them load them as InputStreams via a classloader.
 
Back
Top