New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
port library to newly generified classes in java 7 #3634
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3634?orig=1 |
@adriaanm said: you're compiling code that was developed against non-generic libraries against the "generified" library in order to leverage Java 7, we'd need to port our library so that it compiles against Java 7 libraries, but target Java 6 bytecode when compling because the generics in the Java 7 libs will erase to something compatible with the Java 6 libs, code compiled against (carefully crafted) Java 7 libraries should run unmodified on both versions 6&7. note that the compiler does not need to be changed for any of this, it's simply a build process thing (what could possible go wrong) furthermore, Java 7 is still quite a ways off (let's say 1-2 years), so I don't think this is going to be high priority for the time being still, it doesn't hurt to give it a shot (if you aim right) |
@paulp said: % JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home scala29
Welcome to Scala version 2.9.0.r23690-b20101205201822 (OpenJDK 64-Bit Server VM, Java 1.7.0-internal).
Type in expressions to have them evaluated.
Type :help for more information.
scala> new javax.swing.DefaultComboBoxModel { }
<console>:6: error: illegal inheritance;
anonymous class $$anon inherits different type instances of trait ListModel:
javax.swing.ListModel[E] and javax.swing.ListModel[E]
new javax.swing.DefaultComboBoxModel { }
^ This interesting situation arises because javax.swing.ComboBoxModel extends javax.swing.ListModel. But the interface is javax.swing.ListModel, so it swallows up the type parameter in an unrecoverable way. Meanwhile javax.swing.AbstractListModel extends javax.swing.ListModel. In scala.swing this hits in ComboBox: // the code at present
new AbstractListModel with ComboBoxModel
// what it needs to look like
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] ^ Reclassifying as defect and kicking back to scala reviewer. It's worth the trouble to figure something out now that lets us use java7, even if we don't anticipate supporting it for a long while yet. |
@odersky said: |
@paulp said:
I can't yet say more errors don't arise at some later stage, but as far as I know yes, that one error is the entire obstacle. I'm with you on avoiding a dribble of gross hacks. I will verify that this is the one and only issue and report back. |
@paulp said: https://github.com/downloads/paulp/scala-full/scala-2.9.0.r23705-java7.tgz Also, of possibly tremendous interest to OSX users (it was for me anyway) there is a project creating 32-bit and 64-bit OSX openjdk builds. There are installers and they coexist peacefully with the shipped jdks in apple's new /Library/Java/JavaVirtualMachines space. So it lowers the barrier to using openjdk for appropriate tasks down around zero. |
@ijuma said: In the context of using Java 7 with Scala, the standard library will be changed to use some of the Java 7 features, which may (or may not) impact Scala: http://blogs.sun.com/darcy/entry/project_coin_minty_fresh_libraries |
@adriaanm said: Or did you skip the offending java bits? |
@paulp said: https://github.com/scala/scala/tree/openjdk It's all legit except for the issue already outlined in this ticket. For that one I brought out good old Mr. Null and his bag of nullities. + // XXX Returning null since there's not yet a workaround for SI-3634.
+ def newConstantModel[A](items: Seq[A]): ComboBoxModel = { null |
@paulp said:
...and to disentangle these not quite intersecting thoughts, ijuma is presumably talking about submitting a java patch. I'm not your man for that. My world starts where their world ends. |
@adriaanm said:
|
@paulp said:
Wait, we means something other than that sometimes? I'm having the sinking feeling I should have looked that word up a long time ago. |
@ijuma said: http://mail.openjdk.java.net/pipermail/jdk7-dev/2011-January/001813.html |
@ijuma said: https://bugs.openjdk.java.net/attachment.cgi?id=191&action=diff I have asked if there is a plan to fix this before the release of Java 7. I'll update this issue if/when there's a reply. |
@soc said: |
@ijuma said: http://mail.openjdk.java.net/pipermail/jdk7-dev/2011-March/001947.html |
@soc said: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7029316 I hope this helps ... |
@ijuma said: http://hg.openjdk.java.net/jdk7/jdk7/jdk/rev/ea6bd2607399 A new binary snapshot should be out this week and then we should try to build Scala with it. |
@soc said: |
@ijuma said: |
@ijuma said: |
@paulp said: |
@paulp said: |
@paulp said: |
@paulp said: |
@soc said: The changes necessary to compile scala.swing with Java 7 are here: |
On the theory java 7 will come out someday, we should have a strategy in mind for dealing with it. As things stand it looks to me like we would have to fork java6 and java7 versions. This is due to the generification of certain classes such as javax.swing.Jlist:
[http://java.sun.com/javase/6/docs/api/javax/swing/JList.html java 6 JList]
[http://download.java.net/jdk7/docs/api/javax/swing/JList.html java 7 JList]
Since #2970 was closed wontfix I take it improving support for raw types is not on the agenda. I spent some time tweaking trunk toward compiling but any change which leads toward success on java 7 invariably leads toward failure on java 6. This may be a bullet we just have to take, but I'm opening this so everyone knows the gun has been fired.
The outcome of compiling trunk scala.swing against java7:
The text was updated successfully, but these errors were encountered: