sun jdk-1-5-0 compiler bug

R

Reinhard B.

Hello!

Here is a bug, that all versions of SUN java 1-5-0 compilers seem to have.

The bug is, that a class, extending a base class, cannot be compiled
(because of a (wrong) error message), except you compile
both base class and sub class together.

Try this:
Write to classes, store them in appropriate files:

--------------------Base.java--------------------
public class Base {

protected class Inner <T> {
}

protected Inner<String> constructInnerOfString (String s) {
return new Inner<String>();
}

}
--------------------/Base.java--------------------

--------------------Sub.java--------------------
public class Sub extends Base {

private Inner<String> innerStr = constructInnerOfString("");

}
--------------------/Sub.java--------------------

Now compile:
javac -classpath . Base.java Sub.java
It works.

Now compile only the sub class:
javac -classpath . Sub.java

Ooops, you will get this (wrong) compiler error message:
Sub.java:4: incompatible types
found : Base.Inner<java.lang.String>
required: Base.Inner<java.lang.String>
private Inner<String> innerStr = constructInnerOfString("");
^
1 error

The problem seem to occur every time, you assign it to a variable.
If you assign the variable 'innerStr' in a constructor, you will get it,
too.
If you just call the method constructInnerOfString(...), you will get it
not.

Is this compiler bug known?
Or is it a new one?
Does anybody know anything about it?

Greetings

Reinhard Bellmann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top