views:

124

answers:

1

Hey everyone,

Has anyone ever heard of overriding too many classes in Java? Perhaps this issue is just related to BlackBerry development, but I was wondering if it is an issue in Java, too.

Let's say I have the following:

LabelField lblTitle = new LabelField(title) {
    protected void paint(Graphics graphics) {
        graphics.setColor(0x00FFFFFF);
        graphics.clear();
        super.paint(graphics);
    }
};

LabelField lblSubTitle = new LabelField(releaseYear + ", " + rating) {
    protected void paint(Graphics graphics) {
        graphics.setColor(0x00FFFFFF);
        graphics.clear();
        super.paint(graphics);
    }
};

This code works. However, I've noticed that by overriding the paint() method multiple times in many different classes throughout my project, I receive the error:

I/O Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specified

My only solution thus far is to clean up my GUI code...minimize it and reuse it. Perhaps its good that this happened so I can be less careless about creating GUI code all over my classes.

Anyways, I was just wondering if anyone has heard of this before. If you are interested in reading more about the issue I have been facing, check out the following link:

BlackBerry Java Development Forums

+1  A: 

It is unlikely that the number of times you override paint() yields the error you're reporting. It seems that the error is due to a build (compilation) error which prevents the jar from being created. You should therefore try and take a closer look at the error messages reported by your compiler/build tool.

If this does not work, you can try to find the cause of the error by "divide and conquer", as follows: comment out all places where your override paint(). If the problem disappears, uncomment half of these overrides and try again. If the problem comes back comment half of this half (and continue recursively). Otherwise, If the problem is still gone, comment back the 1st half and uncomment the 2nd half (and continue recursively).

Even if you have many places where you override paint(), this type of binary search will converge quite quickly. For example, if you pain twas overridden 256 times you only need eight recursive iterations to find out the one that is causing the problem.

Itay