What version of Java compiler does SBT use? Super strange compiler errors

2.445 visninger
Gå til det første ulæste opslag

benmccann

ulæst,
12. apr. 2012, 18.13.5212.04.2012
til simple-b...@googlegroups.com
Hi,

I'm trying to compile Google Guava with SBT and am getting some exceedingly strange errors.  It compiles fine with Maven, but SBT does not like it at all:

[error] Maps.java:517: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,V>
[error] found   : <K,V>java.util.TreeMap<K,V>
[error] required: java.util.SortedMap<K,V>
[error]     SortedMap<K, V> onlyOnLeft = Maps.newTreeMap(comparator);
[error]                                                 ^
[error] Maps.java:518: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,V>
[error] found   : <K,V>java.util.TreeMap<K,V>
[error] required: java.util.SortedMap<K,V>
[error]     SortedMap<K, V> onlyOnRight = Maps.newTreeMap(comparator);
[error]                                                  ^
[error] Maps.java:520: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,V>
[error] found   : <K,V>java.util.TreeMap<K,V>
[error] required: java.util.SortedMap<K,V>
[error]     SortedMap<K, V> onBoth = Maps.newTreeMap(comparator);
[error]                                             ^
[error] Maps.java:522: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,com.google.common.collect.MapDifference.ValueDifference<V>>
[error] found   : <K,V>java.util.TreeMap<K,V>
[error] required: java.util.SortedMap<K,com.google.common.collect.MapDifference.ValueDifference<V>>
[error]         Maps.newTreeMap(comparator);

To reproduce run "git clone https://code.google.com/p/guava-libraries/" and then place this build.sbt in guava-libraries/guava/

Thanks,
Ben

Paul Phillips

ulæst,
12. apr. 2012, 19.41.0712.04.2012
til simple-b...@googlegroups.com
On Thu, Apr 12, 2012 at 11:13 PM, benmccann <benjamin...@gmail.com> wrote:
> I'm trying to compile Google Guava with SBT and am getting some exceedingly
> strange errors.  It compiles fine with Maven, but SBT does not like it at
> all:

Your problem isn't sbt. I suspect something interesting on your classpath.

% sbt compile
Detected sbt version 0.11.2
Using /Users/paulp/.sbt/0.11.2 as sbt dir, -sbt-dir to override.
[info] Loading global plugins from /Users/paulp/.sbt/0.11.2/plugins
[info] Set current project to guava (in build file:/s/guava-libraries/guava/)
[info] Compiling 388 Java sources to
/s/guava-libraries/guava/target/scala-2.9.1/classes...
[success] Total time: 15 s, completed Apr 13, 2012 12:40:16 AM

Ben McCann

ulæst,
12. apr. 2012, 20.41.1912.04.2012
til simple-b...@googlegroups.com
Hmm, strange, so you were able to compile Guava using my build script?  Shouldn't our classpaths be the same if we were using the same build script?  Any idea how I would print mine out to see if something strange were added?

Does SBT use the Java on your $PATH?  I have Oracle JDK 6 installed on Ubuntu 11.10.  What about you?

Thanks for helping me take a look at this!

-Ben



--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.


Brian Smith

ulæst,
12. apr. 2012, 20.38.1412.04.2012
til simple-b...@googlegroups.com
Seems to be an issue with certain versions of OpenJDK.



--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.

Ben McCann

ulæst,
12. apr. 2012, 20.57.4412.04.2012
til simple-b...@googlegroups.com
Hmm, I'm running the Oracle version of Java.  I do have OpenJDK installed, but it's not the default one on my path.  Is SBT perhaps somehow picking it up anyway?

$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

Ben McCann

ulæst,
12. apr. 2012, 21.10.5112.04.2012
til simple-b...@googlegroups.com
Ooh, actually, I only had the Oracle version of java and not javac, so that might be it.

Ben McCann

ulæst,
13. apr. 2012, 00.08.1413.04.2012
til simple-b...@googlegroups.com
Yep, so SBT uses the javac that is on your path and this was a bug with OpenJDK.  I wrote up some instructions on how to install Oracle JDK.  I followed someone else's originally and they had a poor usage of update-alternatives which changed only my java version and not my javac version, which led to some confusion as well.

Thanks so much for the help on this!

Mark Harrah

ulæst,
13. apr. 2012, 06.35.1713.04.2012
til simple-b...@googlegroups.com
On Thu, 12 Apr 2012 21:08:14 -0700
Ben McCann <b...@benmccann.com> wrote:

> Yep, so SBT uses the javac that is on your path and this was a bug with
> OpenJDK. I wrote up some instructions on how to install Oracle JDK. I
> followed someone else's originally and they had a poor usage of
> update-alternatives which changed only my java version and not my javac
> version, which led to some confusion as well.
> http://www.benmccann.com/dev-blog/installing-oracle-java-jdk-on-ubuntu/

Note that you can control the version of Java used with javaHome:

javaHome := Some(file("/path/to/java/home"))

If you put this in ~/.sbt/global.sbt, it should take effect for all of your projects and plugins built on your machine without having to publish it as part of your build (where it won't work for others).

-Mark

Svar alle
Svar til forfatter
Videresend
0 nye opslag