Skip to content

Commit 95d7ce3

Browse files
committed
Align Path signatures and harden native VM integration test
1 parent 1313daa commit 95d7ce3

File tree

8 files changed

+60
-5
lines changed

8 files changed

+60
-5
lines changed

vm/JavaAPI/src/java/nio/file/Path.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.net.URI;
88
import java.util.Iterator;
99

10-
public interface Path extends Comparable<Path>, Iterable<Path> {
10+
public interface Path extends Comparable<Path>, Iterable<Path>, Watchable {
1111

1212
FileSystem getFileSystem();
1313

@@ -53,9 +53,9 @@ public interface Path extends Comparable<Path>, Iterable<Path> {
5353

5454
File toFile();
5555

56-
Path register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws java.io.IOException;
56+
WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws java.io.IOException;
5757

58-
Path register(WatchService watcher, WatchEvent.Kind<?>... events) throws java.io.IOException;
58+
WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws java.io.IOException;
5959

6060
Iterator<Path> iterator();
6161

vm/JavaAPI/src/java/nio/file/Paths.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ public java.io.File toFile() {
219219
return new java.io.File(rawPath);
220220
}
221221

222-
public Path register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws java.io.IOException {
222+
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws java.io.IOException {
223223
throw new java.io.IOException("WatchService not supported in JavaAPI");
224224
}
225225

226-
public Path register(WatchService watcher, WatchEvent.Kind<?>... events) throws java.io.IOException {
226+
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws java.io.IOException {
227227
throw new java.io.IOException("WatchService not supported in JavaAPI");
228228
}
229229

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package java.nio.file;
2+
3+
public interface WatchEvent<T> {
4+
Kind<T> kind();
5+
int count();
6+
T context();
7+
8+
interface Kind<T> {
9+
String name();
10+
Class<T> type();
11+
}
12+
13+
interface Modifier {
14+
String name();
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package java.nio.file;
2+
3+
import java.nio.file.WatchEvent.Kind;
4+
import java.util.List;
5+
6+
public interface WatchKey {
7+
boolean isValid();
8+
List<WatchEvent<?>> pollEvents();
9+
boolean reset();
10+
void cancel();
11+
Watchable watchable();
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package java.nio.file;
2+
3+
import java.io.Closeable;
4+
import java.io.IOException;
5+
import java.util.concurrent.TimeUnit;
6+
7+
public interface WatchService extends Closeable {
8+
WatchKey poll();
9+
WatchKey poll(long timeout, TimeUnit unit) throws InterruptedException;
10+
WatchKey take() throws InterruptedException;
11+
void close() throws IOException;
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package java.nio.file;
2+
3+
import java.io.IOException;
4+
5+
public interface Watchable {
6+
WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException;
7+
WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException;
8+
}

vm/tests/src/test/java/com/codename1/tools/translator/CleanTargetIntegrationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ static void replaceLibraryWithExecutableTarget(Path cmakeLists, String sourceDir
188188
Files.write(cmakeLists, replacement.getBytes(StandardCharsets.UTF_8));
189189
}
190190

191+
static void stripObjectiveC(Path cmakeLists) throws IOException {
192+
String content = new String(Files.readAllBytes(cmakeLists), StandardCharsets.UTF_8);
193+
content = content.replace(" OBJC", "");
194+
Files.write(cmakeLists, content.getBytes(StandardCharsets.UTF_8));
195+
}
196+
191197
static String runCommand(List<String> command, Path workingDir) throws Exception {
192198
ProcessBuilder builder = new ProcessBuilder(command);
193199
builder.directory(workingDir.toFile());

vm/tests/src/test/java/com/codename1/tools/translator/NativeFilePathVmIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void nativeVmCreatesFilesAndDirectories() throws Exception {
5050
CleanTargetIntegrationTest.patchCn1Globals(srcRoot);
5151
CleanTargetIntegrationTest.writeRuntimeStubs(srcRoot);
5252
CleanTargetIntegrationTest.replaceLibraryWithExecutableTarget(cmakeLists, srcRoot.getFileName().toString());
53+
CleanTargetIntegrationTest.stripObjectiveC(cmakeLists);
5354

5455
Path buildDir = distDir.resolve("build");
5556
Files.createDirectories(buildDir);

0 commit comments

Comments
 (0)