Skip to main content

The Java Bytecode Verifier [Info Blog]

Even though the Java compiler ensures that Java source code does not violate any safety rule, how can we be sure that the bytecode running in our JVM was not created by malicious compiler?


If the code we run was compiled by us or trusted third parties, then we can be sure, but that is not the case with Applets. When we run an Applet, we run untrusted code. We have no way of knowing if it was created using a malicious compiler. Such code could potentially snoop into our computer's memory, or cause programs to fail by corruppting data structures in memory. This is why the JVM looks at every class with suspicion. The class is subjected to a bytecode verification process before it is loaded.

The bytecode is verified by the Bytecode Verifier. It checks the code for the following violations:

* forging of pointers
* violation of access restrictions
* usage of objects in ways that they were not meant to be used (eg: calling a method on an object, which is not a part of that object)

Through the Bytecode verifier, Java adds security checks at runtime to ensure that safety rules are not violated.

Comments

Popular posts from this blog

Running your own one person company

Recently there was a post on PuneTech on mom's re-entering the IT work force after a break. Two of the biggest concerns mentioned were : Coping with vast advances (changes) in the IT landscape Balancing work and family responsibilities Since I have been running a one person company for a good amount of time, I suggested that as an option. In this post I will discuss various aspects of running a one person company. Advantages: You have full control of your time. You can choose to spend as much or as little time as you would like. There is also a good chance that you will be able to decide when you want to spend that time. You get to work on something that you enjoy doing. Tremendous work satisfaction. You have the option of working from home. Disadvantages: It can take a little while for the work to get set, so you may not be able to see revenues for some time. It takes a huge amount of discipline to work without a boss, and without deadlines. You will not get the benefits (insuranc...

Testing Groovy domain classes

If you are trying to test Grails domain class constraints by putting your unit test cases in the 'test/unit' directory, then your tests will fail because the domain objects will not have the 'valdate' method. This can be resolved in two ways: Place the test cases inside test/integration (which will slow things down) Use the method 'mockForConstraintsTests(Trail)' to create mock method in your domain class and continue writing your test cases in 'test/unit' What follows is some example code around this finding. I am working on a Groovy on Grails project for a website to help programmers keep up and refresh their skills. I started with some domain classes and then moved on to write some unit tests. When we create a Grails project using grails create-app , it creates several directories, one of which is a directory called 'test' for holding unit tests. This directory contains two directories, 'unit', and 'integration' for unit and ...

Creating an Eclipse web project using Maven and Struts 1.x

I am doing some Struts work after a long time. Interestingly it is for a Test Driven Development training. A client wants me to do a hands on session, using Struts 1.x, and EJB's. They also want to do the hands on sessions with a small but production project. It seems their developers are tired of Calculator and Shape projects :-) Well I can't really blame them. I have been planning to create some micro applications around diycomputerscience.com . I hope to create each application using a different technology, so I can have several reference points for teaching. For this session I am going to make a web application which will store and display my slides. I am sure you are thinking ... but why not just use SlideShare ? Well besides the fact that I think this makes a great application that is small, but also production quality. Ideal for using to teach. But there are other reasons as well. It is very hard to embed code snippets on Slideshare. Slideshare also does not support co...