Why are classes so easy to decompile

Hello guys,
I was interested in how Java actually works. So i came to the fact that you can decompile classes and get 99% correct output.
Now i compared to the C family, and i've read it is possibly too, but alot harder to do it. (Thats what i've read)
So i'm asking why java classes are so easy to decompile? Can't it be changed so the work of an author is more secure and protected to people who want to rip your source? (I'm talking then about applets)
Please do not flame as this is only a subject i discovered.
Thanks in advance,
jojo123
Edit: changed title :)

jojo123 wrote:
They can obtain the class files as it is an applet, and as far as i know i don't know any method to protect them from getting it?
So they can find out how everything works, and so they can try to cheat by sending wrong values (eg: sending 1000 coins while you only have 1)
But that is fixable server-side.If your fellow students are actively trying to attack your work by grabbing the class files, decompiling them, finding errors, and then demonstrating the errors, then they're doing you a favor. (Well, at least if they tell you what they found.) They're doing you a favor by finding bugs in your program for you. This is called "quality assurance" (aka QA) and companies pay people to do it.
The solution is to write stronger code that doesn't have those errors!
No, you can't prevent people from getting the class files for an applet. The whole point of an applet is that people download it and run it locally. If they can run it, they can decompile it. This is true of any language.
The discussion was actually why they don't update java to prevent it being so easily decompilable, but i don't really got an answer on that.It's not really so easily decompilable. As I said it's really only easier inasmuch as the object code (compiled classes) are more discrete than object code in other languages, and because there's a single virtual machine. Those are both advantages of the language (at least for certain applications, such as the ones that Java has become popular in). So that's why they don't "update java to prevent it being so easily decompilable". It would make the language worse.
Decompiling really isn't a problem.
Keep in mind that a lot of popular languages aren't compiled at all, or they're compiled only at runtime and the scripts are deployed as source code.
Don't worry about it.
Edited by: paulcw on Nov 30, 2009 11:34 AM

Similar Messages

  • Why are JDBC related classes Interfaces???

    Why are the JDBC related classes java.sql.CallableStatement
    java.sql.Connection
    java.sql.PreparedStatement
    java.sql.ResultSet
    java.sql.Statement Interfaces??? Where are the implementations of these interfaces found??? What are the pros and cons involved in doing so???
    thx in advance!!!

    Are these classes Interfaces from the very first release of Java specifications??? I'm quite doubtful
    about this.You're also quite wrong.
    They've been interfaces from the very beginning. If they hadn't been, there's no way JDBC drivers could plug & play as nicely as they do.
    This is the beauty of all interfaces, by the way. It's a design worth emulating in your own work.
    If not, in what release have they been made into Interfaces???Why are you so concerned?

  • Why are my connection bars (internet and phone) blue sometimes and sometimes gray?  I'm sure this is an easy one

    why are my connection bars (internet and phone) blue sometimes and sometimes gray?  I'm sure this is an easy one

    blue means you're connected to Google's servers

  • Why are we using Abstract class?

    Why are we using Abstract class? What is specify use of Abstract class?

    The way I understand it....and I may be wrong because
    I am very new....is that by making the class abstract
    you will add abstract methods to it. Those abstract
    methods MUST be defined in in any subclass that
    inherits from the abstract class thereby making the
    abstract a template for subclasses.
    If your animal class is abstract then you would need
    an abstract method (Which is just siganture, no body)
    of say "numberOfLegs". Then in your dog and cat
    classes which extend animal you must define a
    "numberOfLegs" method with appropriate code.it isn't mandatory for an abstract class to have abstract methods. if a class does have abstract methods, the class must be abstract. but the following is perfectly legal
    public abstract class NoAbstractMethods {
      public void doStuff() {
         // do stuff
    }a subclass of an abstract class can also be abstract, and as such need not implement any additional methods

  • What is the significance of Marker interface? Why are we using, even though

    What is the significance of Marker interface? Why are we using, even though it has no method?

    Well, what's the significance of an interface? They can define a set of methods a class may implement but the class could equally well implement these methods without the interface so why having interfaces at all?
    The answer is that the most important aspect of an interface is that it constitutes a type (you can declare variables of it). And it's a type regardless of how many methods it defines, including none. So the reason for having a marker interface is that you're interested solely in the type aspect of interfaces.

  • Why are getColumnClass/getColumnName in TableModel, not TableColumnModel?

    Shouldn't the TableColumnModel be responsible for keeping information about the table columns? Things such as column classes and names? Why are these things retrieved through TableModel only? This doesn't seem to follow OO concepts, what am I missing?
    Along those same lines, why are methods such as getColumnCount() in both TableModel and TableColumnModel? Again, this seems appropriate to TableColumnModel, but not TableModel, except maybe as a convenience. Am I misunderstanding the roles of these models?

    The TableModel holds the data for each line and for the headers. So it is naturally the place to ask for informations like "how much rows do I have" or "how much columns do I have" or "what is the name of column x".
    The ColumnModel is responsible for specifications on a column, so it naturally should be able to tell all that the TableModel can tell about it, too.
    I don't see a problem in being able to ask both. I would be annoyed if I would not be able to do so and I can see no OO principle broken.
    Rommie.

  • Why are the threads start and terminate randomly?

    Hi there,
    I got the program below. I am wondering why are the threads start and terminate randomly? Everytime, I run the program, it produces different results.
    I know that these four threads have got same normal priority (should be 5), and under windows there is something called timeslice. Then these four threads rotate using this timeslice. How do we know what exactly the timeslice is in seconds? If the timeslice is fix, then why the results are ramdom?
    Thanks in advance!
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package mythreadone;
    * @author Administrator
    public class MyThreadOne implements Runnable {
    String tName;
    Thread t;
    MyThreadOne(String threadName) {
    tName = threadName;
    t = new Thread(this, tName);
    t.start();
    public void run() {
    try {
    System.out.println("Thread: " + tName);
    Thread.sleep(2000);
    } catch (InterruptedException e) {
    System.out.println("Exception: Thread "
    + tName + " interrupted");
    System.out.println("Terminating thread: " + tName);
    public static void main(String args[]) {
    // Why are the threads start and terminate randomly?
    new MyThreadOne("1");
    new MyThreadOne("2");
    new MyThreadOne("3");
    new MyThreadOne("4");
    try {
    Thread.sleep(10000);
    // Thread.sleep(2000);
    } catch (InterruptedException e) {
    System.out.println(
    "Exception: Thread main interrupted.");
    System.out.println(
    "Terminating thread: main thread.");
    1. Firstly, I set in the main function:
    Thread.sleep(10000);
    and I run the program it gives:
    Thread: 1
    Thread: 4
    Thread: 2
    Thread: 3
    Terminating thread: 1
    Terminating thread: 3
    Terminating thread: 4
    Terminating thread: 2
    Terminating thread: main thread.
    BUILD SUCCESSFUL (total time: 10 seconds)
    Run it again, it gives:
    Thread: 2
    Thread: 4
    Thread: 3
    Thread: 1
    Terminating thread: 2
    Terminating thread: 1
    Terminating thread: 3
    Terminating thread: 4
    Terminating thread: main thread.
    BUILD SUCCESSFUL (total time: 10 seconds)
    And my question was why it outputs like this? It suppose to be:
    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Terminating thread: 1
    Terminating thread: 2
    Terminating thread: 3
    Terminating thread: 4
    Terminating thread: main thread.
    BUILD SUCCESSFUL (total time: 10 seconds)
    Why these four threads start and finish randomly each time I run the program? I use Windows, suppose there is a timeslice (i.e. 1 second), these threads have the same priority. Then the threads should start and finish in turn one by one. Am I right?
    2. My second question is:
    When I change the codes in the 'main' function into:
    Thread.sleep(10000); -> Thread.sleep(2000);
    it gives me the results like:
    Thread: 1
    Thread: 4
    Thread: 3
    Thread: 2
    Terminating thread: main thread.
    Terminating thread: 1
    Terminating thread: 4
    Terminating thread: 3
    Terminating thread: 2
    BUILD SUCCESSFUL (total time: 2 seconds)
    Run it again:
    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Terminating thread: 3
    Terminating thread: main thread.
    Terminating thread: 4
    Terminating thread: 2
    Terminating thread: 1
    BUILD SUCCESSFUL (total time: 2 seconds)
    I tried several times. The main thread always terminates before or after the first child thread finished.
    My question is why it doesn't output something like:
    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Terminating thread: 3
    Terminating thread: 4
    Terminating thread: 2
    Terminating thread: main thread.
    Terminating thread: 1
    BUILD SUCCESSFUL (total time: 2 seconds)
    or
    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Terminating thread: 3
    Terminating thread: 4
    Terminating thread: 2
    Terminating thread: 1
    Terminating thread: main thread.
    BUILD SUCCESSFUL (total time: 2 seconds)

    user13476736 wrote:
    Yes, my machine has multi-core. Then you mean that if I got a one core machine the result should always be:
    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Terminating thread: 1
    Terminating thread: 2
    Terminating thread: 3
    Terminating thread: 4
    Terminating thread: main thread.
    BUILD SUCCESSFUL (total time: 10 seconds)
    ???No.
    >
    How to explain my second quesiton then? Why the main thread always terminates before some of the child threads end? Thanks a lot.

  • Why are my search results for mail incomplete?

    Why is it that when I search for emails that I KNOW are in my inbox I cannot find them? This never used to be a problem until I upgraded to Lion. My inbox has close to 7000 emails so it is not practical to manually search through it for an email that is several months old. Why are the search results incomplete? I find this extremely frustrating.

    Had the same problem- called applecare, a mail supervisor walked me through the easy fix-
    (I am no tech so this is in simple terms)
    (Assuming you just upgraded to lion) - the "library" was not "properly rebuilt" - the emails are there but are not fully queriable which is why the "recent" or "post upgrade" emails search properly while the "older" or "pre upgrade" ones don't- the library index needs to be rebuilt (which is much easier than it sounds)
    Steps
    1- Quit Email (fully)
    2- open finder, open "Go"
        Hold the "Option" key on your keyboard - this will expand the menu to show the "Library"
    3- Select the "Library" option, (you can now release the "Option" key).
    4- Open the following folders (Mail,   V2   , Maildata)
    5- Within the Maildata folder there are (3) files which need to be deleted (Trashcan them)
         (envelopeindex, envelopeindex-shm,  envelopeindex-wal)
    6- Reopen Mail / (This will automatically reimport these files,  takes some time depending on how many emails)
    7- Quit mail and Reopen (has to reload for some reason)
    8- The mail program will do some automatic sycronizing  (You will see some the files "Reappear / fill in" while Syncronizing
    9- about 100 (blank or garage or remant emails) loaded to the top of my inbox during this process but everything else was normal-
    Everything now works great 

  • Why public class name should be same as the java file name

    Hi,
    I would like to know, why public class name should be same as the its java file name. Iam in the process of finding the answer to this question. Can someone help me out in finding the explanation.
    Thanks in advance,
    Manoj

    This is a requirement of the Java reference compiler released by Sun. I have used compilers that did not require this, but most seem to follow the reference compiler (which is a very good idea). I am NOT sure if this is specified in the Java Language Specification. Some of the other regulars who are more familiar with the JLS than I may be able to tell you.
    ? {?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Why are iPads so expensive on Ebay?

    I am interested in buying one of these devices, but I just don't have the money to buy a new one at this moment. I don't understand why it is impossible to find one for under $500, yet that is what the 16 GB Wi-Fi version costs from Apple. I understand tax adds about $20, but it still should be quite a bit less for a used model.
    I want one of these, but it's not easy to swing at $500.

    Why are iPads so expensive on Ebay?
    Supply and demand, plus it's the only way some international people can buy one at the moment.
    Check out the new remodeled MacOSG website! 24-hour Apple-related news & support.
     MacOSG: An Apple User Group  iTunes: MacOSG Podcast  Follow us on Twitter: MacOSG

  • Why are people so crazy about XML publisher?

    Why are people so crazy about XML publisher? Maybe there are things I am not aware of, but with the exception of adding the ability to export to Excel from EBS, or having a template for a letter in which a few things will change from copy to copy, I don't see a huge advantage to using it.
    Reports is such a powerful tool and creates so much flexibility in creating graphical documents. Things that are so easy to do in reports, from my experience, is extremely difficult to impossible in XML publisher. In publisher, you have to do a lot of logic yourself that reports would do for you just by saying Yes or No to a property.
    When I first learned about XML publisher, I was really excited about learning to use it. But when I saw how difficult it is to do simple tasks, and how much you have to reinvent the wheel, I became really disappointed. There are lots of examples on the web about how to do this or how to do that with it, but honestly they seem to show you how to go to a lot of trouble to accomplish something that is easy in reports.
    People seem to want to avoid bitmapped reports like the plague, but I think they are extremely underrated.
    What do you guys think? Am I missing something? I would like to hear other opinions and perspectives.
    Thanks,
    Kurz

    Hello Kurz,
    BI Publisher (XML Publisher)
    - can use any relational DB
    - can easily be connected to Oracle Applications (Siebel, JD Edwards, ...)
    - Templates can be edited by users
    - more output formats
    Have a look at http://www.oracle.com/technology/products/xml-publisher/docs/BI_Publisher_for_Apps.pdf
    or the product home at http://www.oracle.com/technology/products/xml-publisher/index.html
    Regards
    Marcus

  • Collect files question. Why are the paths still the same?

    So I collected all of my files from a project and the new project points to all of my old paths. So is there a way to collect the files and have the project point to the new files that were collected? Not sure why they would not be connected. Or am I missing something.....Luckily I had a small project now and replacing the footage is not a big deal, but I have a really big project I'm working on now and it will be pretty time consuming in the future when I access the archived file, to replace all of the missing files. Thanks in advance

    Stanley Arthur wrote:
    I've seen folks belly ache and go on and on about "if you offer this feature, why can't you make it work???", to the point of personal attacks on Adobe support people. To those, I just say "PICK YOUR FREEKIN BATTLES". There are quick and easy workflows that WORK. And that is the point. KEEP WORKING.
    So it's just supposed to be understood that this feature flat out doesn't work and we're supposed to be roll over and be elated that we bought a $1000+ package program that touts certain features that in fact don't work?  That sounds like the Apple fanboys who still swear by Final Cut Pro X despite it being anything BUT pro.  "We don't need Bluray, Steve says so."
    I think Adobe either needs to make it work, and work right, or remove the broken feature until they can get it right.  What's unreasonable about that?  That sounds obvious.  If a feature is listed as a function of the program, we, the consumers have a right to expect that feature to work.
    That's like telling somone who bought a 4x4 truck to pick his battles and only drive on the interstates in the summer and not venture off road or drive through snow because the four-wheel-drive feature doesn't work... and quit complaining it doesn't work, geez!  Keep it on the nice summer highways, buddy.  Duh!
    This guy has every right in the world to expect his four-wheel-drive to work because it's a listed feature of the truck... heck, it even has a 4x4 button to push inside the car... with options!
    At the very least, Adobe needs to make a disclaimer of the like: "use this feature with caution, still in beta.... still.  In fact, it flat out doesn't do as the documentation states, but feel free to give it a try if you want. But please don't come fussing to us if it doesn't work; we're tired of hearing the complaints."
    Or, just disable the dumb thing till they can figure it out like much inferior Edius easily did and, as much as I hate to say it, FCP7.

  • Why are static methods called with null references,valid ?

    This is my code :
    package inheritance;
    public class inh6{
         public static void method(){
         System.out.println("Called");
         public static void main(String[] args){
              inh6 t4 = null;
         t4.method();
    O/P :
    CalledHere t4 is a null reference and yet we are able to call a method on it,why is null pointerexception not thrown.Why are we able to call static methods using null references ?
    t4 is null means it doesnot refer to any memeory address,hence how is method() called correctly.
    I hope i am clear. :)
    Thank you for your consideration.

    punter wrote:
    jverd wrote:
    Memory addresses have nothing to do with it. I doubt memory addresses are even mentioned once in the JLS.
    By memory address i mean the memory location the reference is pointing to.I know what you mean. But if you think it's relevant, can you show me where in the JLS it says anything about memory locations?
    >
    You can do that because a) t4's type is "reference to inh6" and b) method() is declared static, which means that you don't need an object to call it, just the class. That class comes from the compile time type of t4. The fact that t4 is null at runtime is irrelevant.
    So at compile time the type of t4 is inh6 and hence the method is called.Is it ? Had method() not been static a NullPointerException would have been thrown.Correct.
    With non-static, non-private, non-final methods, which implementation of the method gets called is determined at runtime, buy the class of the object on which it's being called. If any one of those "non"s goes away, then the method is entirely determined at compile time, and in the case of static methods, there's no instance necessary to call the method in the first place.

  • Settings: Why are basic webservices settings not included (i.e. OneDrive behavioural settings are hidden in the system tray)?

    What is the idea of a new control panel if you can not in fact get an overview or kind of dash board?
    Settings includes PC+Cloud, i.e. Accounts let you do settings for the cloud, i.e. connect to your live account.
    But why are basic webservices settings not included (i.e. OneDrive settings is in the system tray)?
    Great consolidation is happening now between settings, control panel - i.e. getting rid of obfuscation, blur and complexity between legacy settings (control panel) and actual kind of settings. However do not recreate the problem by leaving the
    next step of integrating cloud settings across the middleware. What is the idea of a new control panel if you can not in fact get an overview or kind of dash board?

    Hi,
    Interesting issue, what about other configuration or settings? Do they work fine or keep reverting after a reboot? Have you tested this issue in another user account? What is the result?
    Regarding to unable to save settigs for current user hive, I doubt whether there's an application you installed recently or an malware\virus changes the permission of registry entry or value of registry keys like
    HKCU\Software\Classes which causes this issue.
    Yolanda Zhu
    TechNet Community Support
    Hmm... I don't understand. Nothing is reverting after a reboot, as well I'm
    not unable to save settings in the current user's hive. The correspondent registry keys can be saved perfectly fine and they are
    deleted, not reverted after a reboot. I pointed to the exact code that does it, the code is located in Microsoft DLL with all certificates and digital signatures intact. Permissions obviously don't matter, since svchost.exe is executed with the highest
    integrity level and under the System user account, the keys in question inherit permissions, which allow System to do whatever it needs without restrictions
    by default, you can't change it to allow more.
    So can you explain how it can be some malware?
    The issue is intermittent, I don't have a 100% repro, therefore “testing” under another user account is doubtful.
    Dei nostra Matrix est.

  • Why are my tags deleted when I replace pages?

    Why are my tags deleted when I replace pages?

    Hi Stephanie,
    My suggested workaround: In Acrobat Pro, in the Page Thumbnails pane, select the pages that you want to replace then right click and select "Delete pages". Then, right-click the page just ahead of where the replacement pages will go, select "Insert pages", and follow the prompts. This is just the way I do it, not the only way.
    Tiger26 is making the excellent suggestion that, prior to inserting pages, encapsulate the tags for the pages to be inserted using a Section tag. This makes the post-insertion chore of dragging the tags to their proper place in the tag structure easier.
    a 'C' student

Maybe you are looking for