Consider this program using http://hg.netbeans.org/binaries/50986B7D247AF02C3DC25CB26B5FC7D5CF1340E6-ini4j-0.4.1.jar as a library:
---%<---
import org.ini4j.Ini;
public class Demo {
public Demo() {
Ini.Section s = new Ini().get("section");
}
}
---%<---
JDK 6's javac accepts this but JDK 7 rejects it with:
Demo.java:4: incompatible types
Ini.Section s = new Ini().get("section");
required: Ini.Section
found: Object
javap for the library reports:
public class org.ini4j.Ini extends org.ini4j.MultiMapImpl<java.lang.String, org.ini4j.Ini$Section> {
// nothing more of interest...
}
public class org.ini4j.MultiMapImpl<K extends java.lang.Object, V extends java.lang.Object> extends java.lang.Object implements org.ini4j.MultiMap<K, V> {
// ...
public V get(java/lang/Object);
public V get(java/lang/Object, int);
// ...
}
public interface org.ini4j.MultiMap<K extends java.lang.Object, V extends java.lang.Object> extends java.lang.Object implements java.util.Map<K, V> {
// ...
public abstract V get(java/lang/Object, int);
// ...
}
Since Ini is a MultiMapImpl<String,Ini.Section>, get(Object) on it should return Ini.Section.
Ini.Section.get(String) is similarly affected; should return String but JDK 7 javac considers it to return Object.
---%<---
import org.ini4j.Ini;
public class Demo {
public Demo() {
Ini.Section s = new Ini().get("section");
}
}
---%<---
JDK 6's javac accepts this but JDK 7 rejects it with:
Demo.java:4: incompatible types
Ini.Section s = new Ini().get("section");
required: Ini.Section
found: Object
javap for the library reports:
public class org.ini4j.Ini extends org.ini4j.MultiMapImpl<java.lang.String, org.ini4j.Ini$Section> {
// nothing more of interest...
}
public class org.ini4j.MultiMapImpl<K extends java.lang.Object, V extends java.lang.Object> extends java.lang.Object implements org.ini4j.MultiMap<K, V> {
// ...
public V get(java/lang/Object);
public V get(java/lang/Object, int);
// ...
}
public interface org.ini4j.MultiMap<K extends java.lang.Object, V extends java.lang.Object> extends java.lang.Object implements java.util.Map<K, V> {
// ...
public abstract V get(java/lang/Object, int);
// ...
}
Since Ini is a MultiMapImpl<String,Ini.Section>, get(Object) on it should return Ini.Section.
Ini.Section.get(String) is similarly affected; should return String but JDK 7 javac considers it to return Object.
- duplicates
-
JDK-6999210 javac should be able to warn of anomalous conditions in classfiles
- Closed
- relates to
-
JDK-6817950 refactor ClassReader to improve attribute handling
- Closed
-
JDK-8010179 Remove transitional target values from javac
- Closed