Skip to content

Commit

Permalink
Lifting restriction that java home cannot be absolute path when jvm l…
Browse files Browse the repository at this point in the history
…abel is used.

PiperOrigin-RevId: 153020672
  • Loading branch information
Googler authored and buchgr committed Apr 13, 2017
1 parent 75381c7 commit 8e04230
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public final class Jvm extends BuildConfiguration.Fragment {

/**
* Creates a Jvm instance. Either the {@code javaHome} parameter is absolute,
* or the {@code jvmLabel} parameter must be non-null. This restriction might
* be lifted in the future. Only the {@code jvmLabel} is optional.
* and/or the {@code jvmLabel} parameter must be non-null. Only the
* {@code jvmLabel} is optional.
*/
public Jvm(PathFragment javaHome, Label jvmLabel) {
Preconditions.checkArgument(javaHome.isAbsolute() ^ (jvmLabel != null));
Preconditions.checkArgument(javaHome.isAbsolute() || jvmLabel != null);
this.javaHome = javaHome;
this.jvmLabel = jvmLabel;
this.java = getJavaHome().getRelative(BIN_JAVA);
Expand Down Expand Up @@ -88,7 +88,7 @@ public Label getJvmLabel() {
* same thing as getJavaExecutable().
*/
public PathFragment getRunfilesJavaExecutable() {
if (jvmLabel == null || jvmLabel.getPackageIdentifier().getRepository().isMain()) {
if (javaHome.isAbsolute() || jvmLabel.getPackageIdentifier().getRepository().isMain()) {
return getJavaExecutable();
}
return jvmLabel.getPackageIdentifier().getRepository().getRunfilesPath().getRelative(BIN_JAVA);
Expand Down

0 comments on commit 8e04230

Please sign in to comment.