Duplicate :
|
FULL PRODUCT VERSION : java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b133) Java HotSpot(TM) 64-Bit Server VM (build 21.0-b03, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux desktop06 2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:46 UTC 2011 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : Currently javax.swing.ListModel is generified, but not its sub-interfaces like ComboBoxModel, MutableComboBoxModel. The problem arises because javax.swing.ComboBoxModel extends javax.swing.ListModel. But the interface is javax.swing.ListModel<E>, so it swallows up the type parameter in an unrecoverable way. Meanwhile javax.swing.AbstractListModel<E> extends javax.swing.ListModel<E>. The Scala compiler rejects this unsound "type swallowing", and can't built against the Java 7 code base any more. While this doesn't violate the spec explicitly, it seems that care has been taken in the past to not introduce Generics with sub-interfaces ignoring them. It should be made sure to not introduce this malpractice into the codebase. There seems to be no technical reason to not add the missing Generics. The relevant bug ticket in Scala's trac is https://lampsvn.epfl.ch/trac/scala/ticket/3634 The mailing list thread is here: http://mail.openjdk.java.net/pipermail/jdk7-dev/2011-January/001813.html A bug report in OpenJDK for the underlying problem is filed under https://bugs.openjdk.java.net/show_bug.cgi?id=100153 A patch is here: https://bugs.openjdk.java.net/attachment.cgi?id=191 REGRESSION. Last worked in version 6u24 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : See https://lampsvn.epfl.ch/trac/scala/ticket/3634#comment:8 I'm currently unable to provide error messages or code myself, because I suffer from some unrelated VM crash (# Problematic frame: V [libjvm.so+0x73b3c9] PSPromotionManager::copy_to_survivor_space(oopDesc*)+0x79) in the Java 7 ea build. I'll add more information as soon as I get it running again. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The sub-interface should carry the generics of the super-interface which will cause the compiler to not reject the code. ACTUAL - The Scala compiler rejects the code. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- new AbstractListModel[something] with ComboBoxModel // what happens, regardless of "something" // // [scalacfork] anonymous class $anon inherits different type instances of trait ListModel: // [scalacfork] javax.swing.ListModel and javax.swing.ListModel[AnyRef] // [scalacfork] new AbstractListModel[AnyRef] with ComboBoxModel { // [scalacfork] ^ // // [scalacfork] anonymous class $anon inherits different type instances of trait ListModel: // [scalacfork] javax.swing.ListModel and javax.swing.ListModel[Nothing] // [scalacfork] new AbstractListModel with ComboBoxModel { // [scalacfork] ^ ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : There is no workaround.