BUG LIST for CODEWARRIOR PRO2

last updated: February 9, 1998

 

COMMENTS:

- This list was compiled to help students understand the error messages they get, and to figure out what might have caused it. It covers the most common error messages, but it is by no means a complete list. If you come across errors not listed here which you do not understand, ask a consultant for help.

- Don’t try to run a program on the Macintosh that you had originally created with the PC version of Codewarrior, or vice versa. A project set up on either machine needs file access paths and libraries specific to that machine. One should create a new program on the target machine and then add your code to the new project.

- Missing and/or misplaced brackets, {}, are far and away the most common source of errors for new programmers. Here is a trick to quickly check the placement of your brackets: double-click on a bracket, and the computer will highlight all of the code which that bracket is responsible for. If it highlights too much or too little, you know that you’ve misplaced some brackets.

 

The following error messages appear in the "ERRORS & WARNINGS WINDOW", which can be quickly referenced on Macs by pressing <APPLE + I>.

 

MOST FREQUENT ERRORS

Error Message

Probable Cause

"(" expected.

- Forgetting a left-parenthesis.

")" expected.

- Forgetting a right-parenthesis, or putting it in the wrong place.

";" expected.

- Forgetting the ";" at the end of a statement.

- This is caused by several other mistakes, but it is usually very easy to spot once you look at the line the error points to.

"{" expected.

- You forgot the left-bracket.

- You made an error while typing the declaration of the class you are working in.

"}" expected.

- You forgot the right-bracket.

- Too many left-brackets in your code.

- The line below the line it points to may contain an error, e.g. declaring something as "public" when you’re only defining a local variable.

Class "classname" not found in type declaration.

- Misspelling a class name when declaring a class or a method.

Class or interface declaration expected.

- Misspelling a keyword, or accidentally changing a comment into actual code.

- Too few/many brackets.

Identifier expected.

- Misspelling "public" in a method declaration.

- Accidentally typing a second period, e.g. "g..setColor" instead of "g.setColor"

Incompatible type for if (or) Incompatible type for =. Can’t convert int to boolean.

- You used an assignment operator (=) instead of equality comparison in a condition in an if- or a while-statement.

- In Java, unlike C, integers and boolean (logical) values are not interchangeable. In "if (b)", b must be a logical expression, not an integer.

Incompatible type for method. Can’t convert "type1" to "type2".

- This is caused when the program expects to be given data of one type, but it is given data of a different type instead.

- TIP: don’t use a double (e.g., 30.0) where an integer (30) is required.

Invalid character in input.

- Illegal character like #, @, etc. in the program that is not part of a string or character literal (e.g., "He hit his thumb and said #!#&**&&^@#%!!" is still a legal string).

Invalid declaration.

- Forgetting a semicolon in the previous line. Also, check that line and the current line for other possible errors.

Method void "methodname" can’t be static in inner class "classname". Only members of interfaces and top-level classes can be static.

- Most commonly caused by incorrect bracket placement, or by missing (or too many) brackets . Check this first!

- Also caused by mistakes or misspellings in class declarations.

Missing term.

- Check the contents of if-statements for errors.

- Caused by typing => or =< instead of <= or >=

No variable "VariableName" defined in class "classname".

- Using a variable from class "classname" that has not yet been defined. Also, misspelled variable names.

Superclass "classname1" of class "classname2" not found.

- This is caused by an error within or before a class declaration that "extends" another class. Check the previous lines for the bug.

Type expected.

- Can be caused by an errant right-bracket in the lines above.

Undefined variable

- You used a variable which had not been declared yet.

Undefined variable or classname: "variable/classname"

- Misspelling a variable or class name, either where it is used, or in its declaration earlier in the program.

Wrong number of arguments in method.

- Having too few/many arguments in a method call. Check the method definition for its correct usage.

 

 

OTHER ERRORS

Error Message

Probable Cause

"class" or "interface" keywords expected.

- Check the first line of the class declaration for errors.

An uncaught Unknown Error occurred in the Java Linker.

- This error comes up if, for example, you comment out your entire program (Hint: with syntax coloring on, doing this would turn most of your statements red).

Arithmetic exception.

- Division by zero!

Array dimension missing.

- When allocating arrays, don’t forget to include their dimensions, e.g. "... = new int[20]"

Class/package "java..." not found in import.

- Misspellings in the import statements at the top of the program.

Failed to load file "filename.java".

- Check the first 10-20 lines of code for the bug. This error may appear if you accidentally comment out your whole program. (Hint: assuming that syntax coloring is left on, your program should not be all red).

Instance variables can’t be void: "methodname".

- Check the brackets surrounding your method declarations.

Invalid cast from "type1" to "type2" (e.g., "from java.lang.String to int").

- This is caused by trying to express an object of one type as an object of a second type, when these two types are incompatible.

Invalid expression statement.

- Check the status of your brackets. This is sometimes caused by using parentheses instead of brackets.

Invalid method declaration; return type required.

- Forgetting to list a return type when you are declaring a new method. If nothing is returned, type "void" for the return type.

Invalid type expression.

- Caused by forgetting the semicolon after a method call.

Method "methodname" not found in class "classname".

- Check the spelling of the method you are using.

Method redefined with different return type...

- When overwriting a previously defined function, one cannot assign to it a different return type.

Methods can’t be overwritten to be more private. Method "methodname" is public in class "classname".

- When overwriting a previously defined function, one cannot declare it to be more private than it had been.

No method matching "methodname" found in class "classname".

- Check your method call for errors. For example, calling a method without using any parameters can give this error if the method requires certain parameters.

Statement expected.

- Can be caused by declaring a variable "public" or "private" somewhere in the above code, when it’s really just a local variable, e.g. "public int x" instead of "int x"

String not terminated at end of line.

- Forgetting the end-quotes when using strings. (Hint: with program coloring left on, this would turn program statements gray.)

Variable "variablename" may not have been initialized.

- Forgetting to initialize this variable. This may occur if you try to initialize the variable within an if-statement (e.g., int k; if (something) k = 0; k = k+1). If the if-statement isn’t executed, the variable doesn’t get initialized. Solution: initialize it in the declaration (int k=0).

- Caused by improperly declaring a new array. Check your notes for the proper technique.

Warning: inconsistent member declaration. At most one of public, private, or protected may be specified.

- Declaring something as both public and private is an example of an error that will produce this message.

 

 

These last error messages appear in the output window, not in the Errors and Warnings window with the others:

Class CUCSGraphicsApplication not found.Exception occurred during event dispatching: java.lang.ArrayIndex

OutOfBoundsException.

- Be careful when using arrays. In an array of size n, the highest position in the array is only at array[n-1]

Referencing an array element that is too large or too small will terminate your program with this error message.

Exception occurred during event dispatching: java.lang.String

IndexOutOfBoundsException: String index out of range...

-The program is terminated if an attempt is made to reference strings’ characters past their bounds.

 

Other symptoms: Random weirdness, repeated crashes, Mac type 11 errors, or other unusual behavior when trying to compile or run a program. Often reproducible.

Possible problem: The project data created by Codewarrior may have become corrupted.

What may be happening: The project file contains various data and bookkeeping information used by the Codewarrior IDE to keep track of the parts of the program and to build an executable program from them. The IDE also creates a folder whose name is the project file name followed by Data (i.e., pgm2.mcp Data). This folder contains other IDE-generated files, including the compiled (byte code) version of the Java program and symbol table files used by the debugger. It is possible for the data in these files to become corrupted and, if that happens, attempts to run the program can produce odd behavior, including machine crashes.

Solution 1: In the Codewarrior IDE, select Project>Remove Object Code to remove the object code from the project. Then, from the desktop (not inside the IDE), find the folder containing the project file and project Data folder. Drag the Data folder into the trash.

Try running the program again. The IDE will usually be able to successfully recreate the object code and Data folder and then run the program.

Solution 2: If the previous solution doesn’t work, delete both the project file and the project Data folder by dragging them to the trash. Then create a new project file somewhere else on the disk, selecting the appropriate stationery. Drag the new project file into the folder containing the program’s source files. Then open the new project file (double-click) and add the program’s files to the project (Project>Add Files... or drag-and-drop inside the Codewarrior IDE).

One or the other of these solutions will clear up almost all unusual crashes. If Codewarrior continues to crash, or has similar problems with two or more different projects, try restarting the computer. (That loads fresh copies of the operating system and Codewarrior, replacing possibly damaged copies in main storage.) If the behavior persists, you may need to delete Codewarrior and reinstall it.