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

bootstrap/nailgun minor cleanup #41

Merged
merged 2 commits into from
Mar 6, 2016
Merged

bootstrap/nailgun minor cleanup #41

merged 2 commits into from
Mar 6, 2016

Conversation

tpolecat
Copy link
Contributor

@tpolecat tpolecat commented Mar 6, 2016

A few minor changes.

  • whitespace, etc., for readability
  • move Dependency into its own compilation unit
  • propagate checked exceptions rather than wrapping

For Java code I prefer to propagate checked exceptions in the method types rather than wrapping them in RuntimeException or simply marking everything as throws Exception. As code evolves this helps prevent inadvertent propagation of exceptions that can actually be handled; the programmer gets no indication due to the outer catch-all.

path = Paths.get(target+file+".jar");
try { url = new URL("https://repo1.maven.org/maven2/org/scala-lang/"+folder+"/"+file+".jar"); }
catch (final MalformedURLException e) { throw new RuntimeException(e); }
hash = hash;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a bug; it was simply reassigning the argument to itself and the hash member remained null. Marking the fields as final exposed this.

@tpolecat
Copy link
Contributor Author

tpolecat commented Mar 6, 2016

re: #32 #35

}

// scala-lang dependency
public static Dependency scala(String target, String scalaVersion, String scalaModule, String hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit bothered - maybe for no good reason - that instantiating a Java dependency requires new Dependency and instantiating a Scala dependency is Dependency.scala. Another option would be to protect the constructor and add Dependency.java so our interface is symmetrical.

That has little to no practical effect, I think, so if you hate it then feel free to ignore me. My feelings will not be hurt. :)

Copy link
Owner

Choose a reason for hiding this comment

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

In case you missed that. bootstrap_scala is tiny a self-contained scala jar downloader, that integrates with the rest of cbt via processes, not via the jvm. It never ends up on the same classpath as CBT itself. So I don't think the internal API of bootstrap_scala matters much.

(We tried but failed at recording the architecture session at NEScala. I'll try to do a screen cast one of these days.)

@farmdawgnation
Copy link
Contributor

Didn't check it out and test it, but it looks good on scan. :)

import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
Copy link
Owner

Choose a reason for hiding this comment

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

I am generally a fan of wild-card imports, because I don't see the value of spending time micro-managing imports and I don't use an IDE that does it for me. I very rarely had bugs because of that. When I did, it was with the areas where Scala's type-safetly is lacking, in particular Any2StringAdd. I think I'd rather try to enforce using ++ everywhere than micromanaging imports, especially when they are all JDK ones. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use wildcard imports when I'm trying to figure out what I'm doing, but I usually turn them into explicit imports as part of general tidying up. To me it's just another source of confusion that I can minimize with a minute or two of work. I don't use an IDE either, so the imports help me figure out where things are coming from.

But you're driving the bus so I can revert this to wildcards if you like.

Copy link
Owner

Choose a reason for hiding this comment

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

na, let's not waste time on going back. The only way is forward ;). And the Java code should be more stable than the rest of the project. LGTM

@cvogt
Copy link
Owner

cvogt commented Mar 6, 2016

+1 for propagating checked exceptions

cvogt added a commit that referenced this pull request Mar 6, 2016
bootstrap/nailgun minor cleanup
@cvogt cvogt merged commit 3d337a8 into cvogt:master Mar 6, 2016
@tpolecat tpolecat deleted the cleanup branch March 6, 2016 17:45
cvogt added a commit that referenced this pull request Mar 6, 2016
Adds Dependency.java to compiled files. Bug introduced in #41
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.

3 participants