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

Backport tools.jar robustness for REPL, fail loud #7652

Closed
scabug opened this issue Jul 12, 2013 · 8 comments
Closed

Backport tools.jar robustness for REPL, fail loud #7652

scabug opened this issue Jul 12, 2013 · 8 comments

Comments

@scabug
Copy link

@scabug scabug commented Jul 12, 2013

After launching the REPL from sbt, the :javap command does not work for class names:

scala> :javap iControl.services.CommonIPPortDefinition

scala> :javap iControl.services.CommonIPPortDefinition

scala> :javap java.lang.Object

@scabug
Copy link
Author

@scabug scabug commented Jul 12, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7652?orig=1
Reporter: Robin Green (greenrd)
Affected Versions: 2.10.0, 2.10.1, 2.10.2

@scabug
Copy link
Author

@scabug scabug commented Jul 12, 2013

Robin Green (greenrd) said:
Scala 2.9.1 prints:

:javap unavailable on this platform.

@scabug
Copy link
Author

@scabug scabug commented Jul 12, 2013

Robin Green (greenrd) said:
Workaround:

scala -toolcp /usr/lib/jvm/jdk1.6.0_32/lib/tools.jar

However, it doesn't look like I can use this workaround from sbt.

@scabug
Copy link
Author

@scabug scabug commented Aug 29, 2013

@som-snytt said:
IIUC, this is a request to backport a fix in 2.10 to search for tools.jar.

IOW, this works in 2.10, and "affects versions" is only 2.9.

https://github.com/scala/scala/blob/v2.10.2/src/compiler/scala/tools/nsc/interpreter/ILoop.scala#L376

@scabug
Copy link
Author

@scabug scabug commented Aug 29, 2013

Robin Green (greenrd) said:
No, it doesn't work in 2.10. The command prints nothing. In Scala 2.9, it at least prints an error message, but it doesn't find the tools.jar in either version.

@scabug
Copy link
Author

@scabug scabug commented Aug 29, 2013

@som-snytt said:
I left my comfort zone and got the versions aligned, but alas IWFM on 2.10.

There was an enhancement for 2.11:

#7410

On Ubuntu it's easy to get JAVA_HOME, java and javac at cross-purposes. In my case, after installing jdk7, it left java at java6. I've forgotten the details except that it was a confusing mode of failure; perhaps it's more confusing on 2.10.

apm@mara:~/tmp/q$ JAVA_HOME=$JAVA6_HOME sbt12
[info] Set current project to default-7bbd7f (in build file:/home/apm/tmp/q/)
> ++ 2.10.2
Setting version to 2.10.2
[info] Set current project to default-7bbd7f (in build file:/home/apm/tmp/q/)
> console
[info] Updating {file:/home/apm/tmp/q/}default-7bbd7f...
[info] Resolving org.scala-lang#scala-library;2.10.2 ...
[info] Done updating.
[info] 'compiler-interface' not yet compiled for Scala 2.10.2. Compiling...
[info]   Compilation completed in 12.899 s
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.10.2 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :javap
:javap [-lcsvp] [path1 path2 ...]

scala> :javap -public scala.Option
Compiled from "Option.scala"

I see there's an about command:

> about
[info] This is sbt 0.12.3
[info] The current project is {file:/home/apm/tmp/q/}default-7bbd7f
[info] The current project is built against Scala 2.10.2
[info] 
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
> 

There's a debug flag that might help. But what does this mean?

$ sbt12 -Dscala.repl.debug=true

Welcome to Scala version 2.10.2 (OpenJDK 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
[info] started at Thu Aug 29 11:21:32 PDT 2013

scala> :javap
:javap unavailable: no tools.jar at /usr/lib/jvm/java-7-openjdk-amd64
:javap not yet working with java 1.7

Not finding tools.jar should be a spurious report.

Running that again with JDK 6 works as expected:

Welcome to Scala version 2.10.2 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
[info] started at Thu Aug 29 11:28:58 PDT 2013

scala> :javap
:javap available.
:javap [-lcsvp] [path1 path2 ...]

scala> :javap java.lang.Object
Compiled from "Object.java"

Also, under debug,

> about
[info] This is sbt 0.12.3
[info] The current project is {file:/home/apm/tmp/q/}default-7bbd7f
[info] The current project is built against Scala 2.9.2
[info] 
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
> console
[info] Starting scala interpreter...
[info] 
[error] (run-main) java.lang.NullPointerException
java.lang.NullPointerException
	at scala.tools.nsc.interpreter.ILoop.<init>(ILoop.scala:68)
	at scala.tools.nsc.InterpreterLoop.<init>(InterpreterLoop.scala:9)
	at scala.tools.nsc.InterpreterLoop.<init>(InterpreterLoop.scala:11)
	at xsbt.ConsoleInterface$$anon$1.<init>(ConsoleInterface.scala:27)
	at xsbt.ConsoleInterface.run(ConsoleInterface.scala:27)

@scabug
Copy link
Author

@scabug scabug commented Aug 29, 2013

@som-snytt said:
Yes, that seems to be the problem, viz, java and JAVA_HOME do not jibe.

I was able to test this way, without munging my environment, thankfully. This is java at v6 and JAVA_HOME at v7; reflective invocation of javap finds the wrong tools.jar.

apm@mara:~/tmp/q$ JAVACMD=$JAVA6_HOME/bin/java JAVA_HOME=$JAVA7_HOME sbt12 
Launching with /home/apm/bin/sbt-0.12.3/bin/sbt-launch.jar
[info] Set current project to default-7bbd7f (in build file:/home/apm/tmp/q/)
> 
> ++ 2.10.2
Setting version to 2.10.2
[info] Set current project to default-7bbd7f (in build file:/home/apm/tmp/q/)
> 
> about
[info] This is sbt 0.12.3
[info] The current project is {file:/home/apm/tmp/q/}default-7bbd7f
[info] The current project is built against Scala 2.10.2
[info] 
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
> console
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.10.2 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :javap
:javap [-lcsvp] [path1 path2 ...]

scala> :javap java.lang.Object

scala> 

It does indeed fail silently. Boy, that's confusing.

@scabug
Copy link
Author

@scabug scabug commented Aug 29, 2013

@som-snytt said:
Let it never be said that :javap command does nothing.

scala/scala#2895

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

Successfully merging a pull request may close this issue.

None yet
2 participants