Skip to content

Commit

Permalink
feat(#5): add puzzle for javac method if we are running on JRE
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 21, 2023
1 parent 2c83ee0 commit c84d32d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/yegor256/Jhome.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public Path java() {
/**
* Find the {@code javac} binary.
* @return The path of it
* @todo #5 The javac binary might not be available in JRE.
* We should check if we are running in JDK or JRE and somehow decide what to
* return in this case or even throw an exception in case of JRE. Maybe an
* {@code Optional<Path>} is also a solution here.
*/
public Path javac() {
return this.home.resolve("bin").resolve("javac");
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/yegor256/JhomeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.hamcrest.Matchers;
import org.hamcrest.io.FileMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

/**
* Test case for {@link Jhome}.
Expand Down Expand Up @@ -61,6 +63,7 @@ void findsRealFile() {
}

@Test
@EnabledForJreRange(min = JRE.JAVA_9)
void findsJavac() {
final Path javac = new Jhome().javac();
MatcherAssert.assertThat(
Expand Down

0 comments on commit c84d32d

Please sign in to comment.