Skip to content
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

warn when targeted bytecode version is lower than version of a dependency #5963

Open
scabug opened this issue Jun 21, 2012 · 2 comments
Open

Comments

@scabug
Copy link

scabug commented Jun 21, 2012

There is no bytecode version warning when compiling with a dependency that is higher than the target. e.g. compiling with scala compiler 2.10.0-M4 with JDK6 with a dependency jar of java 7 doesn't raise warnings (maybe it shouldn't be allowed at all, because it only leads to confusion). So the client code is silently compiled to bytecode 49. When running on jre5 or jre6 this results in an error:

C:\java-gearman-service-0.6.1>java -cp .;java-gearman-service-0.6.1.jar;slf4j-api-1.6.4.jar;slf4j-simple-1.6.4.jar;c:\scala-2.10.0-M4\lib\* echo.EchoWorkerServer
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/gearman/GearmanFunction : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at echo.EchoWorkerServer$.<init>(EchoWorkerServer.scala:10)
        at echo.EchoWorkerServer$.<clinit>(EchoWorkerServer.scala)
        at echo.EchoWorkerServer.main(EchoWorkerServer.scala)

The java compiler does raise warnings. It is probably recommendable to compile to a target of the highest bytecode version of the dependencies to avoid versioning problems in the depedency chain in runtime.

C:\java-gearman-service-0.6.1\examples>javac -cp .;..\java-gearman-service-0.6.1.jar -d . *java
warning: org\gearman\Gearman.class(org\gearman:Gearman.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.

And by default it would compile to bytecode 51.

@scabug
Copy link
Author

scabug commented Jun 21, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5963?orig=1
Reporter: DaveScala (davescala)
Affected Versions: 2.9.2, 2.10.0-M4

@scabug
Copy link
Author

scabug commented Jun 21, 2012

DaveScala (davescala) said:
For some reason Improvement has by default read only Priority Blocker but it should be low priority

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

No branches or pull requests

2 participants