I've noticed four bugs that users should be aware of:
abstract class A
{
abstract int a();
abstract int b();
abstract int c();
}
abstract class B extends A
{
int a()
{
return 2;
}
// The problem is right here: while methods b() and c() should be
// "inherited abstractly," they are not. Therefore a class that
// extends B does not have to implement b() and c().
}
class C extends B
{
int b()
{
return 4;
}
// This class should not compile because method c() is not implemented.
// However, because of the J++ bug, it does.
}
Workarounds:
abstract int b(); abstract int c();
in the definition for class B.
null. The following code example illustrates:
class A
{
final B b = new B();
// This does compile, but a build on the whole project will fail (with the infamous
// "Internal Compiler Error") because we marked variable b to be final. I guess the
// compiler has a hard time deciding how to build the constructor for class A because
// it has to create the instance of B before the instance of A.
class B
{
int a()
{
return -2;
}
}
}
Workarounds:
final class A
{
A()
{
b = new B();
}
final B b;
private final class B
{
int a()
{
return -2;
}
}
}
+= operator, as below:final String s = "abc"; s += "def";
The JDK compiler rejects this as a syntax error, but J++ compiles it without errors.
abstract class a
{
abstract int f();
}
class b extends a
{
int f()
{
return 4;
}
private boolean f; // Because we declared this field, J++ thinks
// we didn't implement f()
}
Workarounds:
Jonas Gifford, January 14, 2004