I tried to compile cjava 1.0 on VC 6.0 and got lquite a
lot of errors. Tracing them done (one was the already
mentioned string.h/String.h problem). I found really a
lot of code that under no cicrumstance should compile
in any machine.
Some examples:
In Boolean.cpp:
bool Boolean::equals(Object* obj)
{
if(obj == NULL)
return false;
if (strcmp(obj->getName(),"Boolean") == 0) {
return value == ((Boolean)obj).booleanValue();
}
return false;
}
You can but you never should cast Object* to Boolean,
but to Boolean*.
Integer.h:
Instead of declaring
char* getName();
it must be
virtual const char* getName();
due to declaration in Object.h. Same for Long.h,
Short.h etc.
The virtual keyword for overriding virtual function is
missing nearly anywhere in header files.
Integer.cpp:
int Integer::compareTo(Object* o) {
return compareTo((Integer*)o);
}
Either a check for type name or dynamic_cast<> should
be used. Current code really is begging for beeing
crashed. Same for short.cpp, long.cpp etc.
Last not least, there are far too many includes in
header files, which in nearly all cases are not needed.
They should be moves to cpp files, to avoid unnessary
dependencies.