Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit f76dd98

Browse files
authored
Merge pull request #8 from JaroslavTulach/CompileOnJDK8
Make the project compilable on vanilla JDK8
2 parents 3d9b658 + 4f0566b commit f76dd98

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ os:
22
- linux
33
- osx
44

5+
osx_image: xcode9.3
6+
57
language: java
68

79
jdk:
10+
- openjdk8
811
- openjdk11
912

1013
env:

pom.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,88 @@
149149
</plugins>
150150
</build>
151151
</profile>
152+
<profile>
153+
<id>jdk8</id>
154+
<activation>
155+
<jdk>1.8</jdk>
156+
<file>
157+
<missing>${java.home}/lib/truffle/truffle-api.jar</missing>
158+
</file>
159+
</activation>
160+
<dependencies>
161+
<dependency>
162+
<groupId>org.graalvm.sdk</groupId>
163+
<artifactId>graal-sdk</artifactId>
164+
<version>${graalvm.version}</version>
165+
<scope>compile</scope>
166+
</dependency>
167+
<dependency>
168+
<groupId>org.graalvm.js</groupId>
169+
<artifactId>js</artifactId>
170+
<version>${graalvm.version}</version>
171+
<scope>runtime</scope>
172+
</dependency>
173+
<dependency>
174+
<groupId>org.graalvm.js</groupId>
175+
<artifactId>js-scriptengine</artifactId>
176+
<version>${graalvm.version}</version>
177+
<scope>runtime</scope>
178+
</dependency>
179+
<dependency>
180+
<groupId>org.graalvm.tools</groupId>
181+
<artifactId>profiler</artifactId>
182+
<version>${graalvm.version}</version>
183+
<scope>runtime</scope>
184+
</dependency>
185+
<dependency>
186+
<groupId>org.graalvm.tools</groupId>
187+
<artifactId>chromeinspector</artifactId>
188+
<version>${graalvm.version}</version>
189+
<scope>runtime</scope>
190+
</dependency>
191+
</dependencies>
192+
<build>
193+
<plugins>
194+
<plugin>
195+
<groupId>org.codehaus.mojo</groupId>
196+
<artifactId>exec-maven-plugin</artifactId>
197+
<version>1.6.0</version>
198+
<executions>
199+
<execution>
200+
<id>default-cli</id>
201+
<goals>
202+
<goal>exec</goal>
203+
</goals>
204+
<configuration>
205+
<arguments>
206+
<argument>-classpath</argument>
207+
<classpath/>
208+
<argument>com.mycompany.app.App</argument>
209+
</arguments>
210+
</configuration>
211+
</execution>
212+
<execution>
213+
<id>nograal</id>
214+
<goals>
215+
<goal>exec</goal>
216+
</goals>
217+
<configuration>
218+
<arguments>
219+
<argument>-classpath</argument>
220+
<!-- automatically creates the classpath using all project dependencies, also adding the project build directory -->
221+
<classpath/>
222+
<argument>com.mycompany.app.App</argument>
223+
</arguments>
224+
</configuration>
225+
</execution>
226+
</executions>
227+
<configuration>
228+
<executable>${JAVA_HOME}/bin/java</executable>
229+
</configuration>
230+
</plugin>
231+
</plugins>
232+
</build>
233+
</profile>
152234
</profiles>
153235
<build>
154236
<plugins>

src/test/java/com/mycompany/app/AppTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.mycompany.app;
22

33
import static org.junit.Assert.fail;
4+
import org.junit.Assume;
45
import org.junit.BeforeClass;
56
import org.junit.Test;
67

@@ -14,6 +15,7 @@ public static void nashornBenchmark() throws Exception {
1415

1516
@Test
1617
public void testGraalPolyglotSpeed() throws Exception {
18+
assertGraalVMOrJDK11();
1719
long graalJS = App.benchGraalPolyglotContext();
1820
if (nashorn < graalJS) {
1921
fail(String.format("Graal.js (%d ms) should be faster than Nashorn (%d ms).", graalJS, nashorn));
@@ -22,9 +24,21 @@ public void testGraalPolyglotSpeed() throws Exception {
2224

2325
@Test
2426
public void testGraalScriptEngineSpeed() throws Exception {
27+
assertGraalVMOrJDK11();
2528
long graalJS = App.benchGraalScriptEngine();
2629
if (nashorn < graalJS) {
2730
fail(String.format("Graal.js (%d ms) should be faster than Nashorn (%d ms).", graalJS, nashorn));
2831
}
2932
}
33+
34+
private void assertGraalVMOrJDK11() {
35+
if (System.getProperty("java.vm.name").contains("GraalVM")) {
36+
return;
37+
}
38+
try {
39+
Class.forName("java.lang.Module");
40+
} catch (ClassNotFoundException ex) {
41+
Assume.assumeNoException("Skipping the test on regular JDK8", ex);
42+
}
43+
}
3044
}

0 commit comments

Comments
 (0)