Skip to content

Add console to bridge #1314

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

Merged
merged 9 commits into from
Jun 12, 2016
Merged

Conversation

felixmulder
Copy link
Contributor

This PR does two things:

  1. Adds the ability to use console from within an sbt-session that is using the dotty-bridge
  2. Creates an aggregated subproject in the build file so that we may publish the correct snapshot artifacts using sbt dotty-core/publishLocal or to deploy real snapshots: sbt dotty-core/publish

classpathString: String,
initialCommands: String,
cleanupCommands: String,
loader: ClassLoader,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loader isn't passed to the REPL, is that a TODO? If yes that should be noted in a comment

Copy link
Contributor Author

@felixmulder felixmulder Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it isn't necessary to pass the loader (here atm) - but if a modified loader is passed somehow, it makes sense that it be propagated to the REPL. Will add that in the morning :) thanks!


import scala.util.Try

class CombinedClassLoader(loaders: List[ClassLoader]) extends ClassLoader {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this guy needs to go away - not sure how yet though. Every other solution seems to create a circular dependency on sbt 👎

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Does scalac do something similar?

Copy link
Contributor Author

@felixmulder felixmulder Jun 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They just set it as the class loader - but that doesn't work for us. So I decided that it would be a good idea to merge the ClassLoaders and look through both of them when searching for classes (which works).

But I don't like this solution - if you have a better one - I'm all ears.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it work for us? Can't we replace parentClassLoader in val classLoader with the classloader given by sbt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I would advise against making a custom subclass of ClassLoader because it can very easily not do what you think it should do, and it's hard to debug, but I don't know enough about the situation here to say for sure.

@felixmulder felixmulder force-pushed the topic/bridge-repl branch 2 times, most recently from 28706f6 to 9e76529 Compare June 9, 2016 09:37
Since you still need to depend on multiple artifacts from within the
dotty project, a unified project is not feasible. A plugin would work
better of course.
@felixmulder felixmulder changed the title Add console to bridge, create aggregated subproject Add console to bridge Jun 10, 2016
@felixmulder
Copy link
Contributor Author

This feels stable enough for review now - @DarkDimius

val parent = new URLClassLoader(compilerClasspath.toArray, parentClassLoader)
new AbstractFileClassLoader(virtualDirectory, parent)
lazy val parent = new URLClassLoader(compilerClasspath.toArray,
classOf[Interpreter].getClassLoader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Interpreter instead of CompilingInterpreter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - I think this was originally written by @odersky

@DarkDimius
Copy link
Contributor

LGTM, otherwise.
I prefer to fast-track this PR, as publishing snapshots depends on it.

@DarkDimius DarkDimius merged commit c7d1826 into scala:master Jun 12, 2016
@allanrenucci allanrenucci deleted the topic/bridge-repl branch December 14, 2017 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants