xsbt compatibility with java 7 #208

Closed
baron- opened this Issue Sep 29, 2011 · 2 comments

Comments

Projects
None yet
3 participants

baron- commented Sep 29, 2011

Sbt compile appears to finish, though with warnings. The proguard action fails because proguard 4.4 doesn't support java 7.

Solution

Bumping proguard to 4.7 beta and making this change (thanks mharrah!) is enough to get a working sbt-launch.jar

-       private def libraryFilter = "(!META-INF/**,!*.properties,!scala/actors/**.!scala/util/parsing/*.class,!scala/xml/**.class,!scala/package$.class,**.class)"
+       private def libraryFilter = "(!META-INF/**,!*.properties,!scala/actors/**.!scala/util/parsing/*.class,**.class)"

@harrah harrah closed this in 38909d7 Oct 1, 2011

Trying to build the latest SBT (0.12.0-SNAPSHOT) under Java 1.7.0_03 and latest Scala (2.9.2) works (assuming I replace %% with % and add _2.9.1 for scalacheck&&specs in libraryDependencies in project/Util.scala), however proguard fails with:

E:\_\Scala\xsbt>sbt proguard

E:\_\Scala\xsbt>set SCRIPT_DIR=C:\Program Files (x86)\Scala\bin\

E:\_\Scala\xsbt>"c:\program files (x86)\java\jre7\bin\java" -XX:+TieredCompilation -XX:+UseStringCache -XX:+UseNUMA -XX:ReservedCodeCacheSize=64m  -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=128M -jar "C:\Program Files (x86)\Scala\bin\..\sbt\sbt-launch.jar" proguard
Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future
[info] Loading global plugins from C:\Users\Sandro\.sbt\plugins
[info] Loading project definition from E:\_\Scala\xsbt\project
[info] Set current project to xsbt (in build file:/E:/_/Scala/xsbt/)
[info] ProGuard, version 4.4
[info] Reading program jar [C:\Users\Sandro\.ivy2\cache\org.apache.ivy\ivy\jars\ivy-2.2.0.jar] (filtered)
[info] Reading program jar [C:\Users\Sandro\.ivy2\cache\jline\jline\jars\jline-1.0.jar] (filtered)
[info] Reading program jar [C:\Users\Sandro\.sbt\boot\scala-2.9.2\lib\scala-library.jar] (filtered)
[info] Reading program directory [E:\_\Scala\xsbt\launch\interface\target\classes] (filtered)
[info] Reading program jar [E:\_\Scala\xsbt\launch\target\launcher-0.12.0-SNAPSHOT.jar]
[info] Reading library jar [C:\Program Files (x86)\Java\jre7\lib\rt.jar]
[error] Error: Can't read [proguard.ClassPathEntry@d4d66b] (Can't process class [com/oracle/net/Sdp$1.class] (Unsupported version number [51.0] for class format))
[error] {file:/E:/_/Scala/xsbt/}xsbt/proguard:proguard: Proguard failed with nonzero exit code (1)
[error] Total time: 6 s, completed 13.04.2012. 23:39:18

Is there a setting or something where I could at least try having SBT use Proguard 4.7 (stable for 5 months) or even 4.8 (in beta)?

Thanks.

I'm apparently blind, since the setting is in project/Proguard.scala.

However, switching from 4.4 to 4.7 produced a " net.sf.proguard#proguard;4.7: not found" missing dependency.

Upon further inspection, it seems that the package was changed from proguard to proguard-core, and there indeed exists a proguard-base-4.7 jar:

E:\_\Scala\xsbt>sbt proguard

E:\_\Scala\xsbt>set SCRIPT_DIR=C:\Program Files (x86)\Scala\bin\

E:\_\Scala\xsbt>"c:\program files (x86)\java\jre7\bin\java" -XX:+TieredCompilation -XX:+UseStringCache -XX:+UseNUMA -XX:ReservedCodeCacheSize=64m -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=128M -jar "C:\Program Files (x86)\Scala\bin\..\sbt\sbt-launch.jar" proguard
Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future
[info] Loading global plugins from C:\Users\Sandro\.sbt\plugins
[info] Loading project definition from E:\_\Scala\xsbt\project
[info] Compiling 1 Scala source to E:\_\Scala\xsbt\project\target\scala-2.9.1\sbt-0.12\classes...
[warn] there were 3 deprecation warnings; re-run with -deprecation for details
[warn] one warning found
[info] Set current project to xsbt (in build file:/E:/_/Scala/xsbt/)
[info] Updating {file:/E:/_/Scala/xsbt/}xsbt...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Resolving org.scala-tools.sxr#sxr_2.9.0;0.2.7 ...
[info] Resolving net.sf.proguard#proguard-base;4.7 ...
[info] Resolving net.sf.proguard#proguard-parent;4.7 ...
[info] downloading http://repo1.maven.org/maven2/net/sf/proguard/proguard-base/4.7/proguard-base-4.7.jar ...
[info]  [SUCCESSFUL ] net.sf.proguard#proguard-base;4.7!proguard-base.jar (4377ms)
[info] Done updating.
[info] ProGuard, version 4.7
[info] Reading program jar [C:\Users\Sandro\.ivy2\cache\org.apache.ivy\ivy\jars\ivy-2.2.0.jar] (filtered)
[info] Reading program jar [C:\Users\Sandro\.ivy2\cache\jline\jline\jars\jline-1.0.jar] (filtered)
[info] Reading program jar [C:\Users\Sandro\.sbt\boot\scala-2.9.2\lib\scala-library.jar] (filtered)
[info] Reading program directory [E:\_\Scala\xsbt\launch\interface\target\classes] (filtered)
[info] Reading program jar [E:\_\Scala\xsbt\launch\target\launcher-0.12.0-SNAPSHOT.jar]
[info] Reading library jar [C:\Program Files (x86)\Java\jre7\lib\rt.jar]
[info] Preparing output jar [E:\_\Scala\xsbt\target\sbt-launch-0.12.0-SNAPSHOT.jar]
[info]   Copying resources from program jar [C:\Users\Sandro\.ivy2\cache\org.apache.ivy\ivy\jars\ivy-2.2.0.jar] (filtered)
[info]   Copying resources from program jar [C:\Users\Sandro\.ivy2\cache\jline\jline\jars\jline-1.0.jar] (filtered)
[info]   Copying resources from program jar [C:\Users\Sandro\.sbt\boot\scala-2.9.2\lib\scala-library.jar] (filtered)
[info]   Copying resources from program directory [E:\_\Scala\xsbt\launch\interface\target\classes] (filtered)
[info]   Copying resources from program jar [E:\_\Scala\xsbt\launch\target\launcher-0.12.0-SNAPSHOT.jar]
[success] Total time: 56 s, completed 14.04.2012. 00:03:16

It seems that everything works.

[update]

.. Maybe not. Replacing the stable sbt-launch.jar with target/sbt-launch-0.12.0-SNAPSHOT.jar (and after renaming):

E:_\Scala\xsbt>"c:\program files (x86)\java\jre7\bin\java" -XX:+TieredCompilation -XX:+UseStringCache -XX:+UseNUMA -XX:
ReservedCodeCacheSize=64m -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnable
d -XX:MaxPermSize=128M -jar "C:\Program Files (x86)\Scala\bin..\sbt\sbt-launch.jar"
Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future
Exception in thread "main" java.lang.NoClassDefFoundError: scala/package$
at scala.Predef$.(Predef.scala:89)
at scala.Predef$.(Predef.scala)
at scala.Array$.unapplySeq(Array.scala:415)
at xsbt.boot.Boot$.main(Boot.scala:11)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException: scala.package$
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment